forked from GNUsocial/gnu-social
Public stream uses IDs method
Public stream now uses IDs method
This commit is contained in:
parent
10ef8a2f71
commit
a4d959b8a2
@ -635,25 +635,58 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
|
||||
{
|
||||
$ids = Notice::stream(array('Notice', '_publicStreamDirect'),
|
||||
array(),
|
||||
'public',
|
||||
$offset, $limit, $since_id, $before_id, $since);
|
||||
|
||||
$parts = array();
|
||||
return Notice::getStreamByIds($ids);
|
||||
}
|
||||
|
||||
$qry = 'SELECT * FROM notice ';
|
||||
function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
|
||||
{
|
||||
$notice = new Notice();
|
||||
|
||||
$notice->selectAdd(); // clears it
|
||||
$notice->selectAdd('id');
|
||||
|
||||
$notice->orderBy('id DESC');
|
||||
|
||||
if (!is_null($offset)) {
|
||||
$notice->limit($offset, $limit);
|
||||
}
|
||||
|
||||
if (common_config('public', 'localonly')) {
|
||||
$parts[] = 'is_local = 1';
|
||||
$notice->whereAdd('is_local = 1');
|
||||
} else {
|
||||
# -1 == blacklisted
|
||||
$parts[] = 'is_local != -1';
|
||||
$notice->whereAdd('is_local != -1');
|
||||
}
|
||||
|
||||
if ($parts) {
|
||||
$qry .= ' WHERE ' . implode(' AND ', $parts);
|
||||
if ($since_id != 0) {
|
||||
$notice->whereAdd('id > ' . $since_id);
|
||||
}
|
||||
|
||||
return Notice::getStream($qry,
|
||||
'public',
|
||||
$offset, $limit, $since_id, $before_id, null, $since);
|
||||
if ($before_id != 0) {
|
||||
$notice->whereAdd('id < ' . $before_id);
|
||||
}
|
||||
|
||||
if (!is_null($since)) {
|
||||
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ($notice->find()) {
|
||||
while ($notice->fetch()) {
|
||||
$ids[] = $notice->id;
|
||||
}
|
||||
}
|
||||
|
||||
$notice->free();
|
||||
$notice = NULL;
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
function addToInboxes()
|
||||
@ -990,7 +1023,7 @@ class Notice extends Memcached_DataObject
|
||||
return $ids;
|
||||
}
|
||||
|
||||
$laststr = common_cache_key($idkey.';last');
|
||||
$laststr = $cache->get($idkey.';last');
|
||||
|
||||
if (!empty($laststr)) {
|
||||
$window = explode(',', $laststr);
|
||||
@ -1013,7 +1046,7 @@ class Notice extends Memcached_DataObject
|
||||
$window = call_user_func_array($fn, array_merge($args, array(0, NOTICE_CACHE_WINDOW,
|
||||
0, 0, null)));
|
||||
|
||||
$windowstr = implode(',', $new_window);
|
||||
$windowstr = implode(',', $window);
|
||||
|
||||
$result = $cache->set($idkey, $windowstr);
|
||||
$result = $cache->set($idkey . ';last', $windowstr);
|
||||
|
Loading…
Reference in New Issue
Block a user