From 0b8a2997fe4062583a8083b1361537a6e5a9c2dd Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 14 Dec 2023 08:14:24 +0100 Subject: [PATCH] api work, add account id, add "starred_only" switch --- src/librssguard/database/databasequeries.cpp | 7 ++++++- src/librssguard/database/databasequeries.h | 1 + src/librssguard/network-web/apiserver.cpp | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librssguard/database/databasequeries.cpp b/src/librssguard/database/databasequeries.cpp index 515bd5716..cdb18e5b9 100644 --- a/src/librssguard/database/databasequeries.cpp +++ b/src/librssguard/database/databasequeries.cpp @@ -1179,6 +1179,7 @@ QList DatabaseQueries::getArticlesSlice(const QSqlDatabase& db, int account_id, bool newest_first, bool unread_only, + bool starred_only, qint64 start_after_article_date, int row_offset, int row_limit) { @@ -1186,6 +1187,7 @@ QList DatabaseQueries::getArticlesSlice(const QSqlDatabase& db, QSqlQuery q(db); QString feed_clause = !feed_custom_id.isEmpty() ? QSL("Messages.feed = :feed AND") : QString(); QString is_read_clause = unread_only ? QSL("Messages.is_read = :is_read AND ") : QString(); + QString is_starred_clause = starred_only ? QSL("Messages.is_important = :is_important AND ") : QString(); QString account_id_clause = account_id > 0 ? QSL("Messages.account_id = :account_id AND ") : QString(); QString date_created_clause; @@ -1206,6 +1208,7 @@ QList DatabaseQueries::getArticlesSlice(const QSqlDatabase& db, " %4 " " %5 " " %6 " + " %7 " " Messages.is_deleted = 0 AND " " Messages.is_pdeleted = 0 " "ORDER BY Messages.date_created %2 " @@ -1215,12 +1218,14 @@ QList DatabaseQueries::getArticlesSlice(const QSqlDatabase& db, feed_clause, date_created_clause, account_id_clause, - is_read_clause)); + is_read_clause, + is_starred_clause)); q.bindValue(QSL(":account_id"), account_id); q.bindValue(QSL(":row_limit"), row_limit); q.bindValue(QSL(":row_offset"), row_offset); q.bindValue(QSL(":feed"), feed_custom_id); q.bindValue(QSL(":is_read"), 0); + q.bindValue(QSL(":is_important"), 1); q.bindValue(QSL(":date_created"), start_after_article_date); if (q.exec()) { diff --git a/src/librssguard/database/databasequeries.h b/src/librssguard/database/databasequeries.h index 92928481c..678a5bd9b 100644 --- a/src/librssguard/database/databasequeries.h +++ b/src/librssguard/database/databasequeries.h @@ -123,6 +123,7 @@ class DatabaseQueries { int account_id, bool newest_first, bool unread_only, + bool starred_only, qint64 start_after_article_date, int row_offset, int row_limit); diff --git a/src/librssguard/network-web/apiserver.cpp b/src/librssguard/network-web/apiserver.cpp index 1e3f8a9ec..b3f68c930 100644 --- a/src/librssguard/network-web/apiserver.cpp +++ b/src/librssguard/network-web/apiserver.cpp @@ -117,8 +117,9 @@ ApiResponse ApiServer::processArticlesFromFeed(const QJsonValue& req) const { int account_id = data.value(QSL("account")).toInt(); bool newest_first = data.value(QSL("newest_first")).toBool(); bool unread_only = data.value(QSL("unread_only")).toBool(); + bool starred_only = data.value(QSL("starred_only")).toBool(); int row_offset = data.value(QSL("row_offset")).toInt(); - int row_limit = data.value(QSL("row_limit")).toInt(); + int row_limit = data.value(QSL("row_limit")).toInt(100000); // NOTE: Fixup arguments. if (feed_id == QSL("0")) { @@ -131,6 +132,7 @@ ApiResponse ApiServer::processArticlesFromFeed(const QJsonValue& req) const { account_id, newest_first, unread_only, + starred_only, start_after_article_date, row_offset, row_limit);