From: Marcus Eggenberger Date: Sun, 22 Feb 2009 16:50:38 +0000 (+0100) Subject: making use of postgres timestamps X-Git-Tag: 0.5-rc1~332 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=91113c1a557409765625c41b05432af6d0f7e9d3 making use of postgres timestamps --- diff --git a/src/core/SQL/PostgreSQL/14/setup_060_backlog.sql b/src/core/SQL/PostgreSQL/14/setup_060_backlog.sql index 1f281b0e..0523fcd6 100644 --- a/src/core/SQL/PostgreSQL/14/setup_060_backlog.sql +++ b/src/core/SQL/PostgreSQL/14/setup_060_backlog.sql @@ -1,6 +1,6 @@ CREATE TABLE backlog ( messageid serial PRIMARY KEY, - time integer NOT NULL, + time timestamp NOT NULL, bufferid integer NOT NULL REFERENCES buffer (bufferid) ON DELETE CASCADE, type integer NOT NULL, flags integer NOT NULL, diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 38d96acf..32429a3a 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -251,7 +251,6 @@ void CoreSession::processMessages() { } messages << Message(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags); } - Core::storeMessages(messages); // FIXME: extend protocol to a displayMessages(MessageList) for(int i = 0; i < messages.count(); i++) { diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index 96805baf..f0978086 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -276,7 +276,7 @@ IdentityId PostgreSqlStorage::createIdentity(UserId user, CoreIdentity &identity return IdentityId(); } - qDebug() << "creatId" << query.first() << query.value(0).toInt(); + query.first(); identityId = query.value(0).toInt(); identity.setId(identityId); @@ -488,7 +488,7 @@ NetworkId PostgreSqlStorage::createNetwork(UserId user, const NetworkInfo &info) return NetworkId(); } - qDebug() << "createNet:" << query.first() << query.value(0).toInt(); + query.first(); networkId = query.value(0).toInt(); if(!networkId.isValid()) { @@ -1120,7 +1120,7 @@ bool PostgreSqlStorage::logMessage(Message &msg) { } QVariantList params; - params << msg.timestamp().toTime_t() + params << msg.timestamp() << msg.bufferInfo().bufferId().toInt() << msg.type() << (int)msg.flags() @@ -1204,7 +1204,7 @@ bool PostgreSqlStorage::logMessages(MessageList &msgs) { for(int i = 0; i < msgs.count(); i++) { Message &msg = msgs[i]; QVariantList params; - params << msg.timestamp().toTime_t() + params << msg.timestamp() << msg.bufferInfo().bufferId().toInt() << msg.type() << (int)msg.flags() @@ -1267,8 +1267,11 @@ QList PostgreSqlStorage::requestMsgs(UserId user, BufferId bufferId, Ms return messagelist; } + QDateTime timestamp; for(int i = 0; i < limit && query.next(); i++) { - Message msg(QDateTime::fromTime_t(query.value(1).toInt()), + timestamp = query.value(1).toDateTime(); + timestamp.setTimeSpec(Qt::UTC); + Message msg(timestamp, bufferInfo, (Message::Type)query.value(2).toUInt(), query.value(5).toString(), @@ -1313,8 +1316,11 @@ QList PostgreSqlStorage::requestAllMsgs(UserId user, MsgId first, MsgId return messagelist; } + QDateTime timestamp; for(int i = 0; i < limit && query.next(); i++) { - Message msg(QDateTime::fromTime_t(query.value(2).toInt()), + timestamp = query.value(1).toDateTime(); + timestamp.setTimeSpec(Qt::UTC); + Message msg(timestamp, bufferInfoHash[query.value(1).toInt()], (Message::Type)query.value(3).toUInt(), query.value(6).toString(),