Skip to content

Commit

Permalink
api work
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Dec 13, 2023
1 parent af04c93 commit 87ccee3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion resources/scripts/web_ui/rssguard.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

.entry {
max-width: 720px;
max-width: 90%;
xborder: 1px solid red;
padding: 20px;
margin: 3px auto;
Expand Down
6 changes: 5 additions & 1 deletion src/librssguard/core/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ QString Enclosures::encodeEnclosuresToString(const QList<Enclosure>& enclosures)
}

Message::Message() {
m_title = m_url = m_author = m_contents = m_rawContents = m_feedId = m_customId = m_customHash = QL1S("");
m_title = m_url = m_author = m_contents = m_rawContents = m_feedId = m_feedTitle = m_customId = m_customHash =
QL1S("");
m_enclosures = QList<Enclosure>();
m_categories = QList<MessageCategory>();
m_accountId = m_id = 0;
Expand Down Expand Up @@ -182,6 +183,8 @@ QJsonObject Message::toJson() const {
obj.insert(QSL("custom_id"), m_customId);
obj.insert(QSL("custom_hash"), m_customHash);
obj.insert(QSL("feed_custom_id"), m_feedId);
obj.insert(QSL("feed_title"), m_feedTitle);
obj.insert(QSL("is_rtl"), m_isRtl);
obj.insert(QSL("enclosures"), Enclosures::encodeEnclosuresToJson(m_enclosures));

return obj;
Expand All @@ -203,6 +206,7 @@ Message Message::fromSqlRecord(const QSqlRecord& record, bool* result) {
message.m_isImportant = record.value(MSG_DB_IMPORTANT_INDEX).toBool();
message.m_isDeleted = record.value(MSG_DB_DELETED_INDEX).toBool();
message.m_feedId = record.value(MSG_DB_FEED_CUSTOM_ID_INDEX).toString();
message.m_feedTitle = record.value(MSG_DB_FEED_TITLE_INDEX).toString();
message.m_title = record.value(MSG_DB_TITLE_INDEX).toString();
message.m_url = record.value(MSG_DB_URL_INDEX).toString();
message.m_author = record.value(MSG_DB_AUTHOR_INDEX).toString();
Expand Down
1 change: 1 addition & 0 deletions src/librssguard/core/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RSSGUARD_DLLSPEC Message {
// to localtime when needed.
QDateTime m_created;
QString m_feedId;
QString m_feedTitle;
int m_accountId;
int m_id;
QString m_customId;
Expand Down
19 changes: 10 additions & 9 deletions src/librssguard/database/databasequeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,31 +1184,32 @@ QList<Message> DatabaseQueries::getArticlesSlice(const QSqlDatabase& db,
int row_limit) {
QList<Message> messages;
QSqlQuery q(db);
QString feed_clause = !feed_custom_id.isEmpty() ? QSL("feed = :feed AND") : QString();
QString feed_clause = !feed_custom_id.isEmpty() ? QSL("Messages.feed = :feed AND") : QString();
QString date_created_clause;

if (start_after_article_date > 0) {
if (newest_first) {
date_created_clause = QSL("date_created < :date_created AND ");
date_created_clause = QSL("Messages.date_created < :date_created AND ");
}
else {
date_created_clause = QSL("date_created > :date_created AND ");
date_created_clause = QSL("Messages.date_created > :date_created AND ");
}
}

q.setForwardOnly(true);
q.prepare(QSL("SELECT %1 "
"FROM Messages "
"WHERE is_deleted = 0 AND "
" is_pdeleted = 0 AND "
" is_read = :is_read AND "
"FROM Messages LEFT JOIN Feeds ON Messages.feed = Feeds.custom_id AND "
" Messages.account_id = Feeds.account_id "
"WHERE Messages.is_deleted = 0 AND "
" Messages.is_pdeleted = 0 AND "
" Messages.is_read = :is_read AND "
//" date_created > :date_created AND "
" %3 "
" %4 "
" account_id = :account_id "
" Messages.account_id = :account_id "
"ORDER BY Messages.date_created %2 "
"LIMIT :row_limit OFFSET :row_offset;")
.arg(messageTableAttributes(true, db.driverName() == QSL(APP_DB_SQLITE_DRIVER)).values().join(QSL(", ")),
.arg(messageTableAttributes(false, db.driverName() == QSL(APP_DB_SQLITE_DRIVER)).values().join(QSL(", ")),
newest_first ? QSL("DESC") : QSL("ASC"),
feed_clause,
date_created_clause));
Expand Down

0 comments on commit 87ccee3

Please sign in to comment.