]> git.wh0rd.org Git - tt-rss.git/commitdiff
bayes: fix check for already categorized articles
authorAndrew Dolgov <noreply@fakecake.org>
Thu, 18 Jun 2015 07:56:42 +0000 (10:56 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Thu, 18 Jun 2015 07:56:42 +0000 (10:56 +0300)
plugins/af_sort_bayes/init.php

index d2e659cae31111d118f05b0ff7a2cdf8bdf52411..0bdfafa1757ca85018e9c040ade236dce7440635 100644 (file)
@@ -263,12 +263,17 @@ class Af_Sort_Bayes extends Plugin {
        function hook_article_filter($article) {
                $owner_uid = $article["owner_uid"];
 
-               $nbs = new NaiveBayesianStorage($owner_uid);
-               $nb = new NaiveBayesianNgram($nbs, 3);
+               // guid already includes owner_uid so we don't need to include it
+               $result = $this->dbh->query("SELECT id FROM {$this->sql_prefix}_references WHERE
+                       document_id = '" . $this->dbh->escape_string($article['guid_hashed']) . "'");
 
-               $ref = $nbs->getReference($article["guid"], false);
+               if (db_num_rows($result) != 0) {
+                       _debug("bayes: article already categorized");
+                       return $article;
+               }
 
-               if (isset($ref["category_id"])) return $article; // already categorized
+               $nbs = new NaiveBayesianStorage($owner_uid);
+               $nb = new NaiveBayesianNgram($nbs, 3);
 
                $categories = $nbs->getCategories();