]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Sitemap/Sitemap_notice_count.php
Merge commit 'refs/merge-requests/166' of git://gitorious.org/statusnet/mainline...
[quix0rs-gnu-social.git] / plugins / Sitemap / Sitemap_notice_count.php
index 673417b788471ea816baf24b1451b086552fe67a..2238ff5218e692efad6e48e6c0f6e2436170f5fd 100644 (file)
@@ -51,7 +51,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
  *
  * @see      DB_DataObject
  */
-
 class Sitemap_notice_count extends Memcached_DataObject
 {
     public $__table = 'sitemap_notice_count'; // table name
@@ -72,7 +71,6 @@ class Sitemap_notice_count extends Memcached_DataObject
      * @return Sitemap_notice_count object found, or null for no hits
      *
      */
-
     function staticGet($k, $v=null)
     {
         return Memcached_DataObject::staticGet('Sitemap_notice_count', $k, $v);
@@ -86,7 +84,6 @@ class Sitemap_notice_count extends Memcached_DataObject
      *
      * @return array array of column definitions
      */
-
     function table()
     {
         return array('notice_date' => DB_DATAOBJECT_DATE + DB_DATAOBJECT_NOTNULL,
@@ -103,7 +100,6 @@ class Sitemap_notice_count extends Memcached_DataObject
      *
      * @return array key definitions
      */
-
     function keys()
     {
         return array('notice_date' => 'K');
@@ -117,7 +113,6 @@ class Sitemap_notice_count extends Memcached_DataObject
      *
      * @return array key definitions
      */
-
     function keyTypes()
     {
         return $this->keys();
@@ -128,7 +123,6 @@ class Sitemap_notice_count extends Memcached_DataObject
         $noticeCounts = self::cacheGet('sitemap:notice:counts');
 
         if ($noticeCounts === false) {
-
             $snc = new Sitemap_notice_count();
             $snc->orderBy('notice_date DESC');
 
@@ -153,7 +147,9 @@ class Sitemap_notice_count extends Memcached_DataObject
                 $noticeCounts[$snc->notice_date] = $snc->notice_count;
             }
 
-            self::cacheSet('sitemap:notice:counts', $noticeCounts);
+            // Cache notice counts for 4 hours.
+
+            self::cacheSet('sitemap:notice:counts', $noticeCounts, null, time() + 4 * 60 * 60);
         }
 
         return $noticeCounts;
@@ -208,6 +204,7 @@ class Sitemap_notice_count extends Memcached_DataObject
     {
         $notice = new Notice();
         $notice->whereAdd('created BETWEEN "'.$d.' 00:00:00" AND "'.self::incrementDay($d).' 00:00:00"');
+        $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
         $n = $notice->count();
 
         return $n;
@@ -233,7 +230,8 @@ class Sitemap_notice_count extends Memcached_DataObject
         $snc = Sitemap_notice_count::staticGet('notice_date', DB_DataObject_Cast::date($d));
 
         if (empty($snc)) {
-            throw new Exception("No such registration date: $d");
+            // TRANS: Exception
+            throw new Exception(_m("No such registration date: $d."));
         }
 
         $orig = clone($snc);