From fee840fbe3c2ec42dd0174ca26060e140001154f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 30 Apr 2008 11:12:41 +0100 Subject: pref-feeds: add action to rescore feeds --- modules/pref-feeds.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'modules/pref-feeds.php') diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 6bd6b4aba..d54f2bdb9 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -473,6 +473,49 @@ clear_feed_articles($link, $id); } + if ($subop == "rescore") { + $ids = split(",", db_escape_string($_GET["ids"])); + + foreach ($ids as $id) { + + $filters = load_filters($link, $id, $_SESSION["uid"], 6); + + $result = db_query($link, "SELECT title, content, link, ref_id FROM + ttrss_user_entries, ttrss_entries + WHERE ref_id = id AND feed_id = '$id' AND + owner_uid = " .$_SESSION['uid']." + ORDER BY updated DESC LIMIT 100"); + + $scores = array(); + + while ($line = db_fetch_assoc($result)) { + + $article_filters = get_article_filters($filters, $line['title'], + $line['content'], $line['link']); + + $new_score = calculate_article_score($article_filters); + + if (!$scores[$new_score]) $scores[$new_score] = array(); + + array_push($scores[$new_score], $line['ref_id']); + } + + foreach (array_keys($scores) as $s) { + if ($s > 1000) { + db_query($link, "UPDATE ttrss_user_entries SET score = '$s', + marked = true WHERE + ref_id IN (" . join(',', $scores[$s]) . ")"); + } else { + db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE + ref_id IN (" . join(',', $scores[$s]) . ")"); + } + } + } + + print __("All done."); + + } + if ($subop == "add") { if (!WEB_DEMO_MODE) { @@ -1020,6 +1063,7 @@ + "; if (get_pref($link, 'ENABLE_FEED_CATS')) { -- cgit v1.2.3