summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/dbcontacts.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-09-27 23:48:00 +0300
committeraunsane <aunsane@gmail.com>2018-09-27 23:48:00 +0300
commitfe0958f789d45915c317db89dce533311c79d016 (patch)
tree97849275b8df8ae9562b4f6eda722feb85959f91 /plugins/Dbx_sqlite/src/dbcontacts.cpp
parent39fdc50b018c989f22c5392aca11da5fc5a482aa (diff)
dbx_sqlite: simple events cache
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_sqlite/src/dbcontacts.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp
index 2bcc0027c8..6a8568e2cb 100644
--- a/plugins/Dbx_sqlite/src/dbcontacts.cpp
+++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp
@@ -24,10 +24,13 @@ void CDbxSQLite::InitContacts()
//m_cache->AddContactToCache(0);
sqlite3_stmt *stmt = nullptr;
- sqlite3_prepare_v2(m_db, "select id from contacts;", -1, &stmt, nullptr);
+ sqlite3_prepare_v2(m_db, "select contact_events.contactid, count(eventid) from contact_events join contacts on contacts.id = contact_events.contactid group by contact_events.contactid;", -1, &stmt, nullptr);
while (sqlite3_step(stmt) == SQLITE_ROW) {
MCONTACT hContact = sqlite3_column_int64(stmt, 0);
- DBCachedContact *cc = m_cache->AddContactToCache(hContact);
+ DBCachedContact *cc = (hContact)
+ ? m_cache->AddContactToCache(hContact)
+ : &m_system;
+ cc->count = sqlite3_column_int64(stmt, 1);
DBVARIANT dbv = { DBVT_DWORD };
cc->nSubs = (0 != GetContactSetting(cc->contactID, META_PROTO, "NumContacts", &dbv)) ? -1 : dbv.dVal;