diff options
author | Brion Vibber <brion@pobox.com> | 2010-11-16 11:10:32 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-11-16 11:10:32 -0800 |
commit | 9b9db3b28aa117085385baa264ba6d8bb928cfac (patch) | |
tree | de33d6b1a9ef7fd63fb2d3ccdce8d4f2e6f593ba /actions/favorited.php | |
parent | 54de6d3260e7fde77eb86079bd67a815930b8b43 (diff) |
Prep for ticket #2895: consolidate common code from PopularNoticeList and FavoritedAction for fetching popular notice lists
Diffstat (limited to 'actions/favorited.php')
-rw-r--r-- | actions/favorited.php | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/actions/favorited.php b/actions/favorited.php index d8980440d..19d49feec 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -185,29 +185,11 @@ class FavoritedAction extends Action function showContent() { - $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff')); - $cutoff = sprintf("fave.modified > '%s'", - common_sql_date(time() - common_config('popular', 'cutoff'))); - - $qry = 'SELECT notice.*, '. - $weightexpr . ' as weight ' . - 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . - "WHERE $cutoff " . - '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', - $qry, - 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); |