]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/favorited.php
Merge branch 'master' into 0.9.x
[quix0rs-gnu-social.git] / actions / favorited.php
index 150b67b0b09451f752d226486031de07852e32b7..19d49feecfcc8224d7bb9433ac80965f14163351 100644 (file)
@@ -185,30 +185,11 @@ class FavoritedAction extends Action
 
     function showContent()
     {
-        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.*, '.
-          $weightexpr . ' as weight ' .
-          'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
-          'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' .
-          'ORDER BY weight DESC';
-
-        $offset = ($this->page - 1) * NOTICES_PER_PAGE;
-        $limit  = NOTICES_PER_PAGE + 1;
-
-        if (common_config('db', 'type') == 'pgsql') {
-            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
-        } else {
-            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
-        }
-
-        $notice = Memcached_DataObject::cachedQuery('Notice',
-                                                    sprintf($qry, common_config('popular', 'dropoff')),
-                                                    600);
+        $pop = new Popularity();
+        $pop->offset = ($this->page - 1) * NOTICES_PER_PAGE;
+        $pop->limit  = NOTICES_PER_PAGE;
+        $pop->expiry = 600;
+        $notice = $pop->getNotices();
 
         $nl = new NoticeList($notice, $this);