summaryrefslogtreecommitdiff
path: root/fetchtopicsaction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fetchtopicsaction.cpp')
-rw-r--r--fetchtopicsaction.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/fetchtopicsaction.cpp b/fetchtopicsaction.cpp
index d8ea173..4617280 100644
--- a/fetchtopicsaction.cpp
+++ b/fetchtopicsaction.cpp
@@ -1,4 +1,5 @@
#include <QtCore/QDateTime>
+#include <QtCore/QSet>
#include <QtCore/QDebug>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
@@ -43,7 +44,7 @@ void FetchTopicsAction::execute()
int end = _end;
if (end == FetchAllTopics) {
// Fetch topics in blocks of size 50.
- end = _start + MAX_FORUM_PAGE_SIZE;
+ end = _start + MAX_FORUM_PAGE_SIZE - 1;
// After finishing this action, a new one will be enqueued with the next 50.
}
@@ -63,9 +64,9 @@ void FetchTopicsAction::handleFinishedCall()
db.transaction();
const int total_topic_num = map["total_topic_num"].toInt();
- int expected_end = _end == FetchAllTopics ? _start + MAX_FORUM_PAGE_SIZE : _end;
- QList<int> current_topics = getCurrentDbTopics(_start, expected_end);
- QList<int> unchanged_topics = current_topics;
+ int expected_end = _end == FetchAllTopics ? _start + MAX_FORUM_PAGE_SIZE - 1 : _end;
+ QSet<int> current_topics = QSet<int>::fromList(getCurrentDbTopics(_start, expected_end));
+ QSet<int> unchanged_topics = current_topics;
if (_start >= total_topic_num) {
// Workaround an issue where the service always returns one post.
@@ -119,12 +120,9 @@ void FetchTopicsAction::handleFinishedCall()
goto finish;
}
- unchanged_topics.removeOne(topic_id);
+ unchanged_topics.remove(topic_id);
}
- // "position" would now point to "_end + 1", if we had gotten as
- // many topics as we requested.
-
int fetched_end = position - 1;
bool eof = fetched_end < expected_end;
if (eof) {