Load item/contents in batches.
This commit is contained in:
parent
e02260297d
commit
3bcad1cf84
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
// Misc.
|
// Misc.
|
||||||
#define GREADER_API_EDIT_TAG_BATCH 200
|
#define GREADER_API_EDIT_TAG_BATCH 200
|
||||||
|
#define GREADER_API_ITEM_CONTENTS_BATCH 999
|
||||||
#define GREADER_GLOBAL_UPDATE_THRES 0.5
|
#define GREADER_GLOBAL_UPDATE_THRES 0.5
|
||||||
|
|
||||||
// The Old Reader.
|
// The Old Reader.
|
||||||
|
@ -339,47 +339,54 @@ QList<Message> GreaderNetwork::itemContents(ServiceRoot* root, const QList<QStri
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> msgs;
|
QList<Message> msgs;
|
||||||
|
QList<QString> my_stream_ids(stream_ids);
|
||||||
|
|
||||||
do {
|
while (!my_stream_ids.isEmpty()) {
|
||||||
QString full_url = generateFullUrl(Operations::ItemContents);
|
QList<QString> batch_ids = my_stream_ids.mid(0, GREADER_API_ITEM_CONTENTS_BATCH);
|
||||||
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
|
||||||
|
|
||||||
if (!continuation.isEmpty()) {
|
my_stream_ids = my_stream_ids.mid(GREADER_API_ITEM_CONTENTS_BATCH);
|
||||||
full_url += QSL("&c=%1").arg(continuation);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list inp = boolinq::from(stream_ids).select([this](const QString& id) {
|
do {
|
||||||
return QSL("i=%1").arg(m_service == GreaderServiceRoot::Service::TheOldReader
|
QString full_url = generateFullUrl(Operations::ItemContents);
|
||||||
|
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
|
||||||
|
if (!continuation.isEmpty()) {
|
||||||
|
full_url += QSL("&c=%1").arg(continuation);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list inp = boolinq::from(batch_ids).select([this](const QString& id) {
|
||||||
|
return QSL("i=%1").arg(m_service == GreaderServiceRoot::Service::TheOldReader
|
||||||
? id
|
? id
|
||||||
: QUrl::toPercentEncoding(id));
|
: QUrl::toPercentEncoding(id));
|
||||||
}).toStdList();
|
}).toStdList();
|
||||||
QByteArray input = FROM_STD_LIST(QStringList, inp).join(QSL("&")).toUtf8();
|
QByteArray input = FROM_STD_LIST(QStringList, inp).join(QSL("&")).toUtf8();
|
||||||
QByteArray output_stream;
|
QByteArray output_stream;
|
||||||
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
||||||
timeout,
|
timeout,
|
||||||
input,
|
input,
|
||||||
output_stream,
|
output_stream,
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
{ authHeader() },
|
{ authHeader() },
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
proxy);
|
proxy);
|
||||||
|
|
||||||
if (result_stream.first != QNetworkReply::NetworkError::NoError) {
|
if (result_stream.first != QNetworkReply::NetworkError::NoError) {
|
||||||
qCriticalNN << LOGSEC_GREADER
|
qCriticalNN << LOGSEC_GREADER
|
||||||
<< "Cannot download messages for "
|
<< "Cannot download messages for "
|
||||||
<< stream_ids
|
<< batch_ids
|
||||||
<< ", network error:"
|
<< ", network error:"
|
||||||
<< QUOTE_W_SPACE_DOT(result_stream.first);
|
<< QUOTE_W_SPACE_DOT(result_stream.first);
|
||||||
error = Feed::Status::NetworkError;
|
error = Feed::Status::NetworkError;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msgs.append(decodeStreamContents(root, output_stream, QString(), continuation));
|
msgs.append(decodeStreamContents(root, output_stream, QString(), continuation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
while (!continuation.isEmpty());
|
||||||
}
|
}
|
||||||
while (!continuation.isEmpty());
|
|
||||||
|
|
||||||
error = Feed::Status::Normal;
|
error = Feed::Status::Normal;
|
||||||
return msgs;
|
return msgs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user