]> git.wh0rd.org Git - tt-rss.git/commitdiff
skip counters output when number of unread articles at backend equals frontend
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 12 Feb 2006 08:04:27 +0000 (09:04 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 12 Feb 2006 08:04:27 +0000 (09:04 +0100)
backend.php
config.php-dist
tt-rss.js
update_daemon.php

index d1ff69142ee71fecc1f332a0a14f14cb3625ed8b..16705f47a26800a45b0e7a61739e7743a0b87bed 100644 (file)
 
        /* FIXME this needs reworking */
 
-       function getGlobalCounters($link) {
+       function getGlobalUnread($link) {
                $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries
                        WHERE unread = true AND 
                        ttrss_user_entries.ref_id = ttrss_entries.id AND 
                        owner_uid = " . $_SESSION["uid"]);
                $c_id = db_fetch_result($result, 0, "c_id");
-               print "<counter type=\"global\" id='global-unread' counter='$c_id'/>";
+               return $c_id;
+       }
+
+       function getGlobalCounters($link, $global_unread = -1) {
+               if ($global_unread == -1) {     
+                       $global_unread = getGlobalUnread($link);
+               }
+               print "<counter type=\"global\" id='global-unread' counter='$global_unread'/>";
        }
 
        function getTagCounters($link, $smart_mode = SMART_RPC_COUNTERS) {
                                update_all_feeds($link, $subop == "forceUpdateAllFeeds");
                        }
 
-                       $omode = $_GET["omode"];
-
-                       if (!$omode) $omode = "tfl";
+                       $global_unread_caller = sprintf("%d", $_GET["uctr"]);
+                       $global_unread = getGlobalUnread($link);
 
                        print "<rpc-reply>";
-                       if (strchr($omode, "l")) getLabelCounters($link);
-                       if (strchr($omode, "f")) getFeedCounters($link);
-                       if (strchr($omode, "t")) getTagCounters($link);
-                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
-                               getCategoryCounters($link);
+
+                       if ($global_unread_caller != $global_unread) {
+
+                               $omode = $_GET["omode"];
+        
+                               if (!$omode) $omode = "tfl";
+        
+                               if (strchr($omode, "l")) getLabelCounters($link);
+                               if (strchr($omode, "f")) getFeedCounters($link);
+                               if (strchr($omode, "t")) getTagCounters($link);
+                               if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                                       getCategoryCounters($link);
+                               }
+                               getGlobalCounters($link, $global_unread);
                        }
-                       getGlobalCounters($link);
+                       
                        print "</rpc-reply>";
 
                }
index d322d3a6731197aef18798afbbfc0b8964159b5a..047de65cdaa3a5779601805fdf9803428f4f20b5 100644 (file)
@@ -97,5 +97,8 @@
        define('DISABLE_SESSIONS', false);
        // Never enable this option (kludge for daemon using tt-rss code)
 
+       define('DAEMON_SLEEP_INTERVAL', 120);
+       // Interval between update daemon update runs
+
        // vim:ft=php
 ?>
index 4b1b29b144feaf0e36b54240b1fb0917ef82d41a..989393b037213bea86f41962605e2884e104c80b 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -191,6 +191,7 @@ function scheduleFeedUpdate(force) {
        }
 
        query_str = query_str + "&omode=" + omode;
+       query_str = query_str + "&uctr=" + global_unread;
 
        if (xmlhttp_ready(xmlhttp)) {
                xmlhttp.open("GET", query_str, true);
index d220266fce42e418939700d891305adab066d04c..b780c7f7ef073c7c94f2181a379b553974b97e32 100644 (file)
@@ -5,7 +5,6 @@
 
        declare(ticks = 1);
 
-       define('SLEEP_INTERVAL', 60); // seconds between update runs
        define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-daemon');
        define('DISABLE_SESSIONS', true);
 
@@ -82,8 +81,8 @@
        
                        print "Feed: " . $line["feed_url"] . ": ";
 
-                       printf("(%d ? %d) ", time() - strtotime($line["last_updated"]),
-                               $upd_intl*60);
+                       printf("(%d/%d, %d) ", time() - strtotime($line["last_updated"]),
+                               $upd_intl*60, $owner_uid);
        
                        if (!$line["last_updated"] || 
                                time() - strtotime($line["last_updated"]) > ($upd_intl * 60)) {
@@ -95,9 +94,9 @@
                        }
                }
 
-               print "Sleeping for " . SLEEP_INTERVAL . " seconds...\n";
+               print "Sleeping for " . DAEMON_SLEEP_INTERVAL . " seconds...\n";
                
-               sleep(SLEEP_INTERVAL);
+               sleep(DAEMON_SLEEP_INTERVAL);
        }
 
        db_close($link);