Load item/contents in batches.

This commit is contained in:
Martin Rotter 2021-07-31 19:33:08 +02:00
parent e02260297d
commit 3bcad1cf84
2 changed files with 41 additions and 33 deletions

View File

@ -33,6 +33,7 @@
// Misc.
#define GREADER_API_EDIT_TAG_BATCH 200
#define GREADER_API_ITEM_CONTENTS_BATCH 999
#define GREADER_GLOBAL_UPDATE_THRES 0.5
// The Old Reader.

View File

@ -339,6 +339,12 @@ QList<Message> GreaderNetwork::itemContents(ServiceRoot* root, const QList<QStri
}
QList<Message> msgs;
QList<QString> my_stream_ids(stream_ids);
while (!my_stream_ids.isEmpty()) {
QList<QString> batch_ids = my_stream_ids.mid(0, GREADER_API_ITEM_CONTENTS_BATCH);
my_stream_ids = my_stream_ids.mid(GREADER_API_ITEM_CONTENTS_BATCH);
do {
QString full_url = generateFullUrl(Operations::ItemContents);
@ -348,7 +354,7 @@ QList<Message> GreaderNetwork::itemContents(ServiceRoot* root, const QList<QStri
full_url += QSL("&c=%1").arg(continuation);
}
std::list inp = boolinq::from(stream_ids).select([this](const QString& id) {
std::list inp = boolinq::from(batch_ids).select([this](const QString& id) {
return QSL("i=%1").arg(m_service == GreaderServiceRoot::Service::TheOldReader
? id
: QUrl::toPercentEncoding(id));
@ -369,7 +375,7 @@ QList<Message> GreaderNetwork::itemContents(ServiceRoot* root, const QList<QStri
if (result_stream.first != QNetworkReply::NetworkError::NoError) {
qCriticalNN << LOGSEC_GREADER
<< "Cannot download messages for "
<< stream_ids
<< batch_ids
<< ", network error:"
<< QUOTE_W_SPACE_DOT(result_stream.first);
error = Feed::Status::NetworkError;
@ -380,6 +386,7 @@ QList<Message> GreaderNetwork::itemContents(ServiceRoot* root, const QList<QStri
}
}
while (!continuation.isEmpty());
}
error = Feed::Status::Normal;
return msgs;