]> git.wh0rd.org Git - tt-rss.git/commitdiff
move feedbrowser cache code to functions.php
authorAndrew Dolgov <fox@madoka.spb.ru>
Fri, 16 Jan 2009 09:47:12 +0000 (10:47 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Fri, 16 Jan 2009 09:47:12 +0000 (10:47 +0100)
functions.php
update_feedbrowser.php

index 593edaf1f1038ff76895e31de35777ffab06ef4f..473356886cde2baf82c849f8095ffad5ccfe1a0c 100644 (file)
                        }
                }
        }
+
+       function update_feedbrowser_cache($link) {
+
+               $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
+                       FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf 
+                               WHERE tf.feed_url = ttrss_feeds.feed_url 
+                               AND (private IS true OR feed_url LIKE '%:%@%/%')) 
+                               GROUP BY feed_url ORDER BY subscribers DESC");
+       
+               db_query($link, "BEGIN");
+       
+               db_query($link, "DELETE FROM ttrss_feedbrowser_cache");
+       
+               $count = 0;
+       
+               while ($line = db_fetch_assoc($result)) {
+                       $subscribers = db_escape_string($line["subscribers"]);
+                       $feed_url = db_escape_string($line["feed_url"]);
+       
+                       db_query($link, "INSERT INTO ttrss_feedbrowser_cache 
+                               (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')");
+       
+                       ++$count;
+               }
+       
+               db_query($link, "COMMIT");
+
+               return $count;
+
+       }
 ?>
index b64bb2569e771fb140f0c1c26f20dfe8111bff03..4698918d561cfc82b4956db79e4b4ea3bcf64e07 100644 (file)
 
        init_connection($link);
 
-       $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers
-               FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf 
-                       WHERE tf.feed_url = ttrss_feeds.feed_url 
-                       AND (private IS true OR feed_url LIKE '%:%@%/%')) 
-                       GROUP BY feed_url ORDER BY subscribers DESC");
-
-       db_query($link, "BEGIN");
-
-       db_query($link, "DELETE FROM ttrss_feedbrowser_cache");
-
-       $count = 0;
-
-       while ($line = db_fetch_assoc($result)) {
-               $subscribers = db_escape_string($line["subscribers"]);
-               $feed_url = db_escape_string($line["feed_url"]);
-
-               db_query($link, "INSERT INTO ttrss_feedbrowser_cache 
-                       (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')");
-
-               ++$count;
-       }
-
-       db_query($link, "COMMIT");
+       $count = update_feedbrowser_cache($link);
 
        print "Finished, $count feeds processed.\n";