]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/popularnoticesection.php
Undo my previous change that breaks the Popular Notices section on the public timelin...
[quix0rs-gnu-social.git] / lib / popularnoticesection.php
index 5734d800189d9bdd7be139d85aef94775b8b53c7..cbf458c34f04240bf8890637989be010f6afb6b6 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
     exit(1);
 }
 
-define('NOTICES_PER_SECTION', 5);
-
 /**
  * Base class for sections showing lists of notices
  *
@@ -50,10 +48,16 @@ class PopularNoticeSection extends NoticeSection
 {
     function getNotices()
     {
+        if (common_config('db', 'type') == 'pgsql') {
+            $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))';
+        } else {
+            $weightexpr='sum(exp(-(now() - fave.modified) / %s))';
+        }
+
         $qry = 'SELECT notice.*, '.
-          'sum(exp(-(now() - fave.modified) / %s)) as weight ' .
+          $weightexpr . ' as weight ' .
           'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
-          'GROUP BY fave.notice_id ' .
+          'GROUP BY notice.id ' .
           'ORDER BY weight DESC';
 
         $offset = 0;
@@ -80,4 +84,9 @@ class PopularNoticeSection extends NoticeSection
     {
         return 'popular_notices';
     }
+
+    function moreUrl()
+    {
+        return common_local_url('favorited');
+    }
 }