]> 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 c7c7f02150407a850bbcc8a3172cfd8b05f90dfd..cbf458c34f04240bf8890637989be010f6afb6b6 100644 (file)
@@ -48,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;