]> git.wh0rd.org - tt-rss.git/commitdiff
filter editor: add button to rescore all feeds
authorAndrew Dolgov <fox@madoka.spb.ru>
Sun, 4 May 2008 04:46:14 +0000 (05:46 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Sun, 4 May 2008 04:46:14 +0000 (05:46 +0100)
localized_js.php
modules/pref-feeds.php
modules/pref-filters.php
prefs.js

index 6c1ff7768273af5e321dbd302534414b541bc3c7..7cf96fa4184a61568b8a3a6aa94f96818ff01f00 100644 (file)
@@ -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(
-
 ?>
index 5992d63443006dcd05a6b2a5bf65dfcba816badc..e6689e8247455e12f221fbcb30a9ef0a4735e63d 100644 (file)
 
                }
 
+               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) {
index ce49976730d5329586f80050c02f5c1e1980231d..031e2a24b613740679863ccc70bd01629e181b8e 100644 (file)
                        id=\"create_filter_btn\"
                        value=\"".__('Create filter')."\">"; 
 
+               print "&nbsp;";
+
+               print "<input type=\"submit\" 
+                       class=\"button\" 
+                       onclick=\"rescore_all_feeds()\" 
+                       value=\"".__('Rescore articles')."\">"; 
+
                $result = db_query($link, "SELECT 
                                ttrss_filters.id AS id,reg_exp,
                                ttrss_filter_types.name AS filter_type_name,
index 65fbe87a0d4acd14e4ae064ffe91ff5aaf61ed7b..e3449a238f03f5bc880a23cb9665d9d637624d9f 100644 (file)
--- 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);
+               }
+
+
+}