]> git.wh0rd.org Git - tt-rss.git/commitdiff
bayes: better prefs ui/stats
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 17 Jun 2015 18:40:44 +0000 (21:40 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 17 Jun 2015 18:40:44 +0000 (21:40 +0300)
plugins/af_sort_bayes/init.js
plugins/af_sort_bayes/init.php

index e6523bc4f7d1d1028e26c0f5bcffc8d427eee500..8043ee277106ba3d924bcb0f241b83dc1fa9533f 100644 (file)
@@ -26,6 +26,7 @@ function bayesClearDatabase() {
                                parameters: query,
                                onComplete: function (transport) {
                                        notify(transport.responseText);
+                                       bayesUpdateUI();
                                }
                        });
                }
@@ -35,3 +36,19 @@ function bayesClearDatabase() {
        }
 }
 
+function bayesUpdateUI() {
+       try {
+
+               var query = "backend.php?op=pluginhandler&plugin=af_sort_bayes&method=renderPrefsUI";
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function (transport) {
+                               dijit.byId("af_sort_bayes_prefs").attr("content", transport.responseText);
+                       }
+               });
+
+       } catch (e) {
+               exception_error("showTrgmRelated", e);
+       }
+}
index f0a91009244e8ba24c181b25eb0f996360cdb12d..7e34ceac453ce0822a48f9acc2ad6d80d6d6b841 100644 (file)
@@ -201,18 +201,16 @@ class Af_Sort_Bayes extends Plugin {
                $this->dbh->query("COMMIT");
        }
 
-       function hook_prefs_tab($args) {
-               if ($args != "prefPrefs") return;
-
-               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Bayesian classifier (af_sort_bayes)')."\">";
-
+       function renderPrefsUI() {
                $result = $this->dbh->query("SELECT category, probability, word_count,
                        (SELECT COUNT(id) FROM {$this->sql_prefix}_references WHERE
                                category_id = {$this->sql_prefix}_categories.id) as doc_count
                        FROM {$this->sql_prefix}_categories WHERE owner_uid = " . $_SESSION["uid"]);
 
+               print "<h3>" . __("Statistics") . "</h3>";
+
                print "<table>";
-               print "<tr><th>Category</th><th>Probability</th><th>Word count</th><th>Article count</th></tr>";
+               print "<tr><th>Category</th><th>Probability</th><th>Words</th><th>Articles</th></tr>";
 
                while ($line = $this->dbh->fetch_assoc($result)) {
                        print "<tr>";
@@ -226,10 +224,35 @@ class Af_Sort_Bayes extends Plugin {
 
                print "</table>";
 
+               print "<h3>" . __("Last matched articles") . "</h3>";
+
+               $result = $this->dbh->query("SELECT te.title, category, tf.title AS feed_title
+                       FROM ttrss_entries AS te, ttrss_user_entries AS tu, ttrss_feeds AS tf, {$this->sql_prefix}_references AS tr, {$this->sql_prefix}_categories AS tc
+                       WHERE tf.id = tu.feed_id AND tu.ref_id = te.id AND tc.id = tr.category_id AND tr.document_id = te.guid ORDER BY te.id DESC LIMIT 20");
+
+               print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
+
+               while ($line = $this->dbh->fetch_assoc($result)) {
+                       print "<li>" . $line["category"] . ": " . $line["title"] . " (" . $line["feed_title"] . ")</li>";
+               }
+
+               print "</ul>";
+
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return bayesUpdateUI()\">".
+                       __('Refresh')."</button> ";
+
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return bayesClearDatabase()\">".
                        __('Clear database')."</button> ";
 
                //
+       }
+
+       function hook_prefs_tab($args) {
+               if ($args != "prefPrefs") return;
+
+               print "<div id=\"af_sort_bayes_prefs\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Bayesian classifier (af_sort_bayes)')."\">";
+
+               $this->renderPrefsUI();
 
                print "</div>";
        }