From 95a948a57428f642b15170a36f93b7875e2fa5af Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 4 May 2008 05:46:14 +0100 Subject: [PATCH] filter editor: add button to rescore all feeds --- localized_js.php | 15 ++++++++++++- modules/pref-feeds.php | 47 ++++++++++++++++++++++++++++++++++++++++ modules/pref-filters.php | 7 ++++++ prefs.js | 15 ++++++++++++- 4 files changed, 82 insertions(+), 2 deletions(-) diff --git a/localized_js.php b/localized_js.php index 6c1ff776..7cf96fa4 100644 --- a/localized_js.php +++ b/localized_js.php @@ -131,11 +131,24 @@ print T_js_decl("Unpublish article"); print T_js_decl("You can't clear this type of feed."); print T_js_decl("Erase all non-starred articles in %s?"); print T_js_decl("Mark all articles as read?"); +print T_js_decl("Rescore articles in selected feeds?"); +print T_js_decl("Rescoring selected feeds..."); +print T_js_decl("Rescore articles in all feeds? This operation may take a lot of time."); +print T_js_decl("Rescoring feeds..."); +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( +#print T_js_decl( #print T_js_decl( #print T_js_decl( #print T_js_decl( #print T_js_decl( #print T_js_decl( #print T_js_decl( - ?> diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 5992d634..e6689e82 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -516,6 +516,53 @@ } + if ($subop == "rescoreAll") { + + $result = db_query($link, + "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); + + while ($feed_line = db_fetch_assoc($result)) { + + $id = $feed_line["id"]; + + $filters = load_filters($link, $id, $_SESSION["uid"], 6); + + $tmp_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']." + "); + + $scores = array(); + + while ($line = db_fetch_assoc($tmp_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) { diff --git a/modules/pref-filters.php b/modules/pref-filters.php index ce499767..031e2a24 100644 --- a/modules/pref-filters.php +++ b/modules/pref-filters.php @@ -228,6 +228,13 @@ id=\"create_filter_btn\" value=\"".__('Create filter')."\">"; + print " "; + + print ""; + $result = db_query($link, "SELECT ttrss_filters.id AS id,reg_exp, ttrss_filter_types.name AS filter_type_name, diff --git a/prefs.js b/prefs.js index 65fbe87a..e3449a23 100644 --- a/prefs.js +++ b/prefs.js @@ -1931,7 +1931,7 @@ function rescoreSelectedFeeds() { var ok = confirm(__("Rescore articles in selected feeds?")); if (ok) { - notify_progress("Rescoring selected labels..."); + notify_progress("Rescoring selected feeds..."); xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+ param_escape(sel_rows.toString()), true); @@ -1945,3 +1945,16 @@ function rescoreSelectedFeeds() { return false; } +function rescore_all_feeds() { + var ok = confirm(__("Rescore all articles? This operation may take a lot of time.")); + + if (ok) { + notify_progress("Rescoring feeds..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true); + xmlhttp.onreadystatechange=notify_callback; + xmlhttp.send(null); + } + + +} -- 2.39.5