1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class PopularNoticeStream extends ScopingNoticeStream
- {
- function __construct(Profile $scoped=null)
- {
- parent::__construct(new CachingNoticeStream(new RawPopularNoticeStream(),
- 'popular',
- false),
- $scoped);
- }
- }
- class RawPopularNoticeStream extends NoticeStream
- {
- function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $weightexpr = common_sql_weight('modified', common_config('popular', 'dropoff'));
- $cutoff = sprintf("modified > '%s'",
- common_sql_date(time() - common_config('popular', 'cutoff')));
- $fave = new Fave();
- $fave->selectAdd();
- $fave->selectAdd('notice_id');
- $fave->selectAdd("$weightexpr as weight");
- $fave->whereAdd($cutoff);
- $fave->orderBy('weight DESC');
- $fave->groupBy('notice_id');
- if (!is_null($offset)) {
- $fave->limit($offset, $limit);
- }
-
- $ids = array();
- if ($fave->find()) {
- while ($fave->fetch()) {
- $ids[] = $fave->notice_id;
- }
- }
- return $ids;
- }
- }
|