summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-12-07 16:59:48 +0300
committerAndrew Dolgov <[email protected]>2020-12-07 16:59:48 +0300
commitd06cc8267bb7dfadd3693260af8788aa990a304e (patch)
tree8ac8d8cb5900b17ef637093642737bac4250d176 /classes/feeds.php
parente40b79ab330b93ef14bb6a71e857673721579d68 (diff)
queryFeedHeadlines: bring back DISTINCT for a limited set of columns
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php29
1 files changed, 19 insertions, 10 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 2a929a6ad..c66fe0207 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -1774,20 +1774,24 @@ class Feeds extends Handler_Protected {
if (DB_TYPE == "pgsql") {
$sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND";
$yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw";
+
+ $distinct_columns = str_replace("desc", "", strtolower($order_by));
+ $distinct_qpart = "DISTINCT ON (id, $distinct_columns)";
} else {
$sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND";
$yyiw_qpart = "date_format(date_entered, '%Y-%u') AS yyiw";
+ $distinct_qpart = "DISTINCT"; //fallback
}
if (!$search && !$skip_first_id_check) {
// if previous topmost article id changed that means our current pagination is no longer valid
- $query = "SELECT
- ttrss_feeds.title,
+ $query = "SELECT $distinct_qpart
+ ttrss_entries.id,
date_entered,
- $yyiw_qpart,
+ $yyiw_qpart,
guid,
- ttrss_entries.id,
ttrss_entries.title,
+ ttrss_feeds.title,
updated,
score,
marked,
@@ -1806,9 +1810,9 @@ class Feeds extends Handler_Protected {
$sanity_interval_qpart
$first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
- /*if ($_REQUEST["debug"]) {
- print $query;
- }*/
+ if ($_REQUEST["debug"]) {
+ print "\n*** FIRST ID QUERY ***\n$query\n";
+ }
$res = $pdo->query($query);
@@ -1821,11 +1825,12 @@ class Feeds extends Handler_Protected {
}
}
- $query = "SELECT
+ $query = "SELECT $distinct_qpart
+ ttrss_entries.id AS id,
date_entered,
$yyiw_qpart,
guid,
- ttrss_entries.id,ttrss_entries.title,
+ ttrss_entries.title,
updated,
label_cache,
tag_cache,
@@ -1857,12 +1862,16 @@ class Feeds extends Handler_Protected {
//if ($_REQUEST["debug"]) print $query;
+ if ($_REQUEST["debug"]) {
+ print "\n*** HEADLINES QUERY ***\n$query\n";
+ }
+
$res = $pdo->query($query);
} else {
// browsing by tag
- $query = "SELECT
+ $query = "SELECT $distinct_qpart
date_entered,
guid,
note,