From be574731fcb3db99df04b7300cea184b2780ba12 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 27 Mar 2013 13:34:04 +0400 Subject: [PATCH] modify sorting by date_entered: set date_entered per-batch; use updated as a secondary criteria --- classes/feeds.php | 11 ++++++++--- include/functions.php | 20 ++++++++------------ include/rssfuncs.php | 4 +++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 2c45da2d..2aa567fc 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -351,7 +351,9 @@ class Feeds extends Handler_Protected { # $content_link = "" . # $line["title"] . ""; - $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false); + $updated_fmt = make_local_datetime($this->link, $line["updated"], false); + $date_entered_fmt = T_sprintf("Imported at %s", + make_local_datetime($this->link, $line["date_entered"], false)); if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) { $content_preview = truncate_string(strip_tags($line["content_preview"]), @@ -459,7 +461,9 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= "$updated_fmt"; + $reply['content'] .= "$updated_fmt + "; + $reply['content'] .= "
"; $reply['content'] .= $score_pic; @@ -566,7 +570,8 @@ class Feeds extends Handler_Protected { } } - $reply['content'] .= "$updated_fmt"; + $reply['content'] .= " + $updated_fmt"; $reply['content'] .= "
"; $reply['content'] .= "$score_pic"; diff --git a/include/functions.php b/include/functions.php index 9125247b..bbddd30b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2341,9 +2341,9 @@ if (!$override_order) { if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "date_entered"; + $override_order = "date_entered, updated"; } else { - $override_order = "last_marked DESC, date_entered DESC"; + $override_order = "last_marked DESC, date_entered DESC, updated DESC"; } } @@ -2356,9 +2356,9 @@ if (!$override_order) { if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $override_order = "date_entered"; + $override_order = "date_entered, updated"; } else { - $override_order = "last_published DESC, date_entered DESC"; + $override_order = "last_published DESC, date_entered DESC, updated DESC"; } } @@ -2383,9 +2383,9 @@ $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid); if (DB_TYPE == "pgsql") { - $query_strategy_part .= " AND updated > NOW() - INTERVAL '$intl hour' "; + $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; } else { - $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; + $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; } $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; @@ -2414,9 +2414,9 @@ } if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { - $order_by = "$date_sort_field"; + $order_by = "$date_sort_field, updated"; } else { - $order_by = "$date_sort_field DESC"; + $order_by = "$date_sort_field DESC, updated DESC"; } if ($view_mode != "noscores") { @@ -2500,10 +2500,8 @@ hide_images, unread,feed_id,marked,published,link,last_read,orig_feed_id, last_marked, last_published, - ".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms, $vfeed_query_part $content_query_part - ".SUBSTRING_FOR_DATE."(updated,1,19) as updated_noms, author,score FROM $from_qpart @@ -2544,11 +2542,9 @@ "last_read," . "(SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images," . "last_marked, last_published, " . - SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," . $since_id_part . $vfeed_query_part . $content_query_part . - SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms," . "score "; $feed_kind = "Tags"; diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 130f9142..73fe757c 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -224,6 +224,8 @@ $simplepie_cache_dir = CACHE_DIR . "/simplepie"; + $date_feed_processed = date('Y-m-d H:i'); + if (!is_dir($simplepie_cache_dir)) { mkdir($simplepie_cache_dir); } @@ -626,7 +628,7 @@ '', $no_orig_date, NOW(), - NOW(), + '$date_feed_processed', '$entry_comments', '$num_comments', '$entry_plugin_data', -- 2.39.5