diff options
author | George Hazan <george.hazan@gmail.com> | 2024-07-21 17:21:05 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-07-21 17:21:05 +0300 |
commit | f02dcd42ac54c448d5a3af69be87d971326b61b8 (patch) | |
tree | 1c7f28c5c7b6f1a442655a026c702c45443059d6 | |
parent | 5fd260b7c4c98bfa2d17a301d832a859c2af1f92 (diff) |
fixes #4553 (NewStory: проблема с подсчётом числа событий в истории метаконтакта)
-rw-r--r-- | plugins/Dbx_sqlite/src/dbcontacts.cpp | 16 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbevents.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.h | 3 |
3 files changed, 15 insertions, 6 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp index db392d303d..7f847c44bb 100644 --- a/plugins/Dbx_sqlite/src/dbcontacts.cpp +++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp @@ -14,11 +14,17 @@ void CDbxSQLite::InitContacts() logError(rc, __FILE__, __LINE__);
sqlite3_finalize(stmt);
- sqlite3_prepare_v2(m_db, "SELECT COUNT(1) FROM events_srt WHERE contact_id=0;", -1, &stmt, nullptr);
- rc = sqlite3_step(stmt);
- logError(rc, __FILE__, __LINE__);
- m_system.m_count = sqlite3_column_int64(stmt, 0);
- sqlite3_finalize(stmt);
+ m_system.m_count = GetContactEventCount(0);
+}
+
+int CDbxSQLite::GetContactEventCount(MCONTACT hContact)
+{
+ auto *stmt = InitQuery("SELECT COUNT(1) FROM events_srt WHERE contact_id = ?;", qCntCountEvents);
+ sqlite3_bind_int64(stmt, 1, hContact);
+ logError(sqlite3_step(stmt), __FILE__, __LINE__);
+ int count = sqlite3_column_int64(stmt, 0);
+ sqlite3_reset(stmt);
+ return count;
}
int CDbxSQLite::GetContactCount()
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 38a3546098..3071373b5b 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -713,6 +713,8 @@ BOOL CDbxSQLite::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSu sqlite3_reset(stmt);
if (rc != SQLITE_DONE)
return FALSE;
+
+ ccMeta->m_count = GetContactEventCount(ccMeta->contactID);
}
DBFlush();
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index 40fffafda1..ab45361bdf 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -69,7 +69,8 @@ class CDbxSQLite : public MDatabaseCommon, public MIDatabaseChecker, public MZer // contacts
void InitContacts();
- CQuery qCntCount, qCntAdd, qCntDel, qCntDelSettings, qCntDelEvents, qCntDelEventSrt;
+ int GetContactEventCount(MCONTACT hContact);
+ CQuery qCntCount, qCntAdd, qCntDel, qCntDelSettings, qCntCountEvents, qCntDelEvents, qCntDelEventSrt;
// encryption
void InitEncryption();
|