queryFeedHeadlines:

- there should be no need for DISTINCT query when checking for first id
 - fix DISTINCT query part being undefined when browsing by tags
 - add query debugging for tags
This commit is contained in:
Andrew Dolgov 2020-12-08 16:59:58 +03:00
parent 7608f3d7b0
commit 71c8d8d365
1 changed files with 12 additions and 1 deletions

View File

@ -1785,7 +1785,7 @@ class Feeds extends Handler_Protected {
if (!$search && !$skip_first_id_check) { if (!$search && !$skip_first_id_check) {
// if previous topmost article id changed that means our current pagination is no longer valid // if previous topmost article id changed that means our current pagination is no longer valid
$query = "SELECT $distinct_qpart $query = "SELECT
ttrss_entries.id, ttrss_entries.id,
date_entered, date_entered,
$yyiw_qpart, $yyiw_qpart,
@ -1871,6 +1871,13 @@ class Feeds extends Handler_Protected {
} else { } else {
// browsing by tag // browsing by tag
if (DB_TYPE == "pgsql") {
$distinct_columns = str_replace("desc", "", strtolower($order_by));
$distinct_qpart = "DISTINCT ON (id, $distinct_columns)";
} else {
$distinct_qpart = "DISTINCT"; //fallback
}
$query = "SELECT $distinct_qpart $query = "SELECT $distinct_qpart
date_entered, date_entered,
guid, guid,
@ -1912,6 +1919,10 @@ class Feeds extends Handler_Protected {
//if ($_REQUEST["debug"]) print $query; //if ($_REQUEST["debug"]) print $query;
if ($_REQUEST["debug"]) {
print "\n*** TAGS QUERY ***\n$query\n";
}
$res = $pdo->query($query); $res = $pdo->query($query);
} }