~ci-train-bot/history-service/history-service-ubuntu-yakkety-landing-052

« back to all changes in this revision

Viewing changes to plugins/sqlite/sqlitehistoryplugin.cpp

Merge parent branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <QSqlError>
37
37
#include <QDBusMetaType>
38
38
 
39
 
Q_DECLARE_METATYPE(History::Thread)
40
 
Q_DECLARE_METATYPE(History::Threads)
41
 
 
42
39
QString generateThreadMapKey(const History::Thread &thread)
43
40
{
44
41
    return thread.accountId() + thread.threadId();
45
42
}
46
43
 
 
44
QString generateThreadMapKey(const QString &accountId, const QString &threadId)
 
45
{
 
46
    return accountId + threadId;
 
47
}
 
48
 
47
49
SQLiteHistoryPlugin::SQLiteHistoryPlugin(QObject *parent) :
48
50
    QObject(parent), mInitialised(false)
49
51
{
50
 
    qRegisterMetaType<History::Thread>();
51
 
    qRegisterMetaType<History::Threads>();
52
52
    // just trigger the database creation or update
53
53
    SQLiteDatabase::instance();
54
54
}
132
132
 
133
133
bool SQLiteHistoryPlugin::lessThan(const QVariantMap &left, const QVariantMap &right) const
134
134
{
135
 
    QVariant leftValue = left["lastEventTimestamp"];
136
 
    QVariant rightValue = right["lastEventTimestamp"];
 
135
    QVariant leftValue = left[History::FieldLastEventTimestamp];
 
136
    QVariant rightValue = right[History::FieldLastEventTimestamp];
137
137
 
138
138
    return leftValue < rightValue;
139
139
}
370
370
    if (accountId.isEmpty() || threadId.isEmpty()) {
371
371
        return result;
372
372
    }
373
 
    if (properties.contains("groupingProperty")) {
374
 
        grouped = properties["groupingProperty"].toString() == History::FieldParticipants;
 
373
    if (properties.contains(History::FieldGroupingProperty)) {
 
374
        grouped = properties[History::FieldGroupingProperty].toString() == History::FieldParticipants;
375
375
    }
376
376
    if (grouped) {
377
 
        const QString &threadKey = accountId+threadId;
 
377
        const QString &threadKey = generateThreadMapKey(accountId, threadId);
378
378
        // we have to find which conversation this thread belongs to
379
379
        if (mConversationsCacheKeys.contains(threadKey)) {
380
380
            // found the thread.
755
755
    QSqlQuery attachmentsQuery(SQLiteDatabase::instance()->database());
756
756
    QList<QVariantMap> attachments;
757
757
    bool grouped = false;
758
 
    if (properties.contains("groupingProperty")) {
759
 
        grouped = properties["groupingProperty"].toBool();
 
758
    if (properties.contains(History::FieldGroupingProperty)) {
 
759
        grouped = properties[History::FieldGroupingProperty].toString() == History::FieldParticipants;
760
760
    }
761
761
    while (query.next()) {
762
762
        QVariantMap thread;
769
769
        thread[History::FieldAccountId] = accountId;
770
770
        thread[History::FieldThreadId] = threadId;
771
771
        if (grouped) {
772
 
            const QString &threadKey = accountId+threadId;
 
772
            const QString &threadKey = generateThreadMapKey(accountId, threadId);
773
773
            if (mInitialised && type == History::EventTypeText && 
774
774
                !mConversationsCache.contains(threadKey)) {
775
775
                continue;