1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix DB updating speed

This commit is contained in:
apprb 2014-11-11 10:57:06 +09:00
parent 9e7ee848e8
commit 6dd2293f59
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B

View File

@ -112,6 +112,7 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
QSqlQuery ans = db->exec("select seq from sqlite_sequence where name=\"history\";");
if (ans.first())
{
int idMax = ans.value(0).toInt();
QSqlQuery ret = db->exec("select seq from sqlite_sequence where name=\"sent_status\";");
int idCur = 0;
if (ret.first())
@ -119,10 +120,9 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
idCur = ret.value(0).toInt();
}
int idMax = ans.value(0).toInt();
for (int i = idCur; i < idMax; i++)
if (idCur != idMax)
{
QString cmd = QString("INSERT INTO sent_status (status) VALUES (1)");
QString cmd = QString("INSERT INTO sent_status (id, status) VALUES (%1, 1)").arg(idMax);
db->exec(cmd);
}
}
@ -168,7 +168,7 @@ QList<HistoryKeeper::HistMessage> HistoryKeeper::getChatHistory(HistoryKeeper::C
if (ct == ctSingle)
{
dbAnswer = db->exec(QString("SELECT history.id, timestamp, user_id, message, status FROM history INNER JOIN aliases ON history.sender = aliases.id ") +
QString("INNER JOIN sent_status ON history.id = sent_status.id AND timestamp BETWEEN %1 AND %2 AND chat_id = %3;")
QString("LEFT OUTER JOIN sent_status ON history.id = sent_status.id AND timestamp BETWEEN %1 AND %2 AND chat_id = %3;")
.arg(time64_from).arg(time64_to).arg(chat_id));
} else {
// no groupchats yet