From eb40cc6e0dd0d8ad603010357252adbfe53b9e9a Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Thu, 25 Aug 2011 02:58:23 +0100 Subject: [PATCH] Disabling group cache updating during reindexing. Handled by event handler now. --- DBBackends/RtcomEventLogger.cpp | 92 --------------------------------------- 1 file changed, 92 deletions(-) diff --git a/DBBackends/RtcomEventLogger.cpp b/DBBackends/RtcomEventLogger.cpp index dbea940..c34a8df 100644 --- a/DBBackends/RtcomEventLogger.cpp +++ b/DBBackends/RtcomEventLogger.cpp @@ -523,98 +523,6 @@ void RtcomEventLogger::Reindex() } }while(changesRequired > 0); - // Update the group cache so the last events are correct - { - qDebug() << "Updating most recent events."; - - // Grab group UIDs from group cache - QSqlQuery * dbq(new QSqlQuery( db )); - dbq->setForwardOnly( true ); - - const char * groupUIDListSQL("SELECT group_uid FROM GroupCache"); - if (dbq->exec(groupUIDListSQL)) - { - qDebug() << "Query OK, " << dbq->numRowsAffected() << " rows affected."; - qDebug() << "GroupUIDs:"; - - QSet groupUIDs; - while( dbq->next() ) - { - QString groupUID(dbq->value(0).value()); - - qDebug() << groupUID; - groupUIDs.insert(groupUID); - } - - // Iterate over group UIDS - if(groupUIDs.count() > 0) - { - // Build a batch statement to update every group with - // the most recent event - - // Ignore 'data' failures (i.e. no events but present in the - // cache)- something else's been monkeying with the DB, and - // we can't account for everything. - const QString updateGroupCacheWithLatestEventsSQL( - "UPDATE OR IGNORE GroupCache SET event_id = " - "(SELECT id FROM events WHERE group_uid = \"%1\" " - " ORDER BY id DESC LIMIT 1)" - " WHERE group_uid = \"%1\";"); - QString updateGroupCacheWithLatestEventsBatchSQL; - foreach(QString groupUID, groupUIDs) - { - updateGroupCacheWithLatestEventsBatchSQL.append( - updateGroupCacheWithLatestEventsSQL - .arg(groupUID) - ).append("\n"); - } - - // Execute the statement in single-statement chunks thanks - // to QT's inability to call the SQLite function supporting - // multiple statements - - QSqlQuery * setLatestEventInGroupCacheSQL(new QSqlQuery( db )); - if(NULL != setLatestEventInGroupCacheSQL) - { - setLatestEventInGroupCacheSQL->setForwardOnly( true ); - - if(db.transaction()) - { - QStringList statements = updateGroupCacheWithLatestEventsBatchSQL.trimmed().split(";", QString::SkipEmptyParts); - try - { - for( QStringList::const_iterator currentStatement(statements.constBegin()); currentStatement != statements.constEnd(); ++currentStatement) - { - if ( setLatestEventInGroupCacheSQL->exec( *currentStatement )) - qDebug() << "Query OK, " << setLatestEventInGroupCacheSQL->numRowsAffected() << " rows affected."; - else - { - qDebug() << "Query Failed: " << *currentStatement; - throw std::exception(); - } - } - - qDebug() << "Committing."; - db.commit(); - } - catch(...) - { - qDebug() << "Rolling back."; - db.rollback(); - } - } - else - qDebug() << "Unable to start transaction."; - } - } - } - else - { - qDebug() << "SQL EXEC Error: "<< "EXEC query failed"; - qDebug() << "Query: " << groupUIDListSQL; - } - } - qDebug() << "Closing."; db.close(); QSqlDatabase::removeDatabase( "QSQLITE" ); -- 1.7.9.5