Dropped deprecated timestamp-based 'since' parameter for all API methods. When it sneaks in it can cause some very slow queries due to mismatches with the indexing.
Twitter removed 'since' support some time ago, and we've already removed it from the public timeline, so it shouldn't be missed.
This commit is contained in:
parent
f596e072e7
commit
6b134ae4c7
|
@ -182,11 +182,6 @@ class ApiDirectMessageAction extends ApiAuthAction
|
||||||
$message->whereAdd('id > ' . $this->since_id);
|
$message->whereAdd('id > ' . $this->since_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($since)) {
|
|
||||||
$d = date('Y-m-d H:i:s', $this->since);
|
|
||||||
$message->whereAdd("created > '$d'");
|
|
||||||
}
|
|
||||||
|
|
||||||
$message->orderBy('created DESC, id DESC');
|
$message->orderBy('created DESC, id DESC');
|
||||||
$message->limit((($this->page - 1) * $this->count), $this->count);
|
$message->limit((($this->page - 1) * $this->count), $this->count);
|
||||||
$message->find();
|
$message->find();
|
||||||
|
|
|
@ -152,8 +152,7 @@ class ApiGroupListAction extends ApiBareAuthAction
|
||||||
($this->page - 1) * $this->count,
|
($this->page - 1) * $this->count,
|
||||||
$this->count,
|
$this->count,
|
||||||
$this->since_id,
|
$this->since_id,
|
||||||
$this->max_id,
|
$this->max_id
|
||||||
$this->since
|
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($group->fetch()) {
|
while ($group->fetch()) {
|
||||||
|
|
|
@ -125,8 +125,7 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
|
||||||
($this->page - 1) * $this->count,
|
($this->page - 1) * $this->count,
|
||||||
$this->count,
|
$this->count,
|
||||||
$this->since_id,
|
$this->since_id,
|
||||||
$this->max_id,
|
$this->max_id
|
||||||
$this->since
|
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($profile->fetch()) {
|
while ($profile->fetch()) {
|
||||||
|
|
|
@ -202,11 +202,11 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
|
if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
|
||||||
$notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count,
|
$notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count,
|
||||||
$this->count, $this->since_id,
|
$this->count, $this->since_id,
|
||||||
$this->max_id, $this->since);
|
$this->max_id);
|
||||||
} else {
|
} else {
|
||||||
$notice = $this->user->friendsTimeline(($this->page-1) * $this->count,
|
$notice = $this->user->friendsTimeline(($this->page-1) * $this->count,
|
||||||
$this->count, $this->since_id,
|
$this->count, $this->since_id,
|
||||||
$this->max_id, $this->since);
|
$this->max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
|
|
|
@ -204,8 +204,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
||||||
($this->page-1) * $this->count,
|
($this->page-1) * $this->count,
|
||||||
$this->count,
|
$this->count,
|
||||||
$this->since_id,
|
$this->since_id,
|
||||||
$this->max_id,
|
$this->max_id
|
||||||
$this->since
|
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
|
|
|
@ -200,13 +200,13 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
|
||||||
$notice = $this->user->noticeInbox(
|
$notice = $this->user->noticeInbox(
|
||||||
($this->page-1) * $this->count,
|
($this->page-1) * $this->count,
|
||||||
$this->count, $this->since_id,
|
$this->count, $this->since_id,
|
||||||
$this->max_id, $this->since
|
$this->max_id
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$notice = $this->user->noticesWithFriends(
|
$notice = $this->user->noticesWithFriends(
|
||||||
($this->page-1) * $this->count,
|
($this->page-1) * $this->count,
|
||||||
$this->count, $this->since_id,
|
$this->count, $this->since_id,
|
||||||
$this->max_id, $this->since
|
$this->max_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
|
|
||||||
$notice = $this->user->getReplies(
|
$notice = $this->user->getReplies(
|
||||||
($this->page - 1) * $this->count, $this->count,
|
($this->page - 1) * $this->count, $this->count,
|
||||||
$this->since_id, $this->max_id, $this->since
|
$this->since_id, $this->max_id
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
|
|
|
@ -75,10 +75,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
|
||||||
|
|
||||||
$this->notices = $this->getNotices();
|
$this->notices = $this->getNotices();
|
||||||
|
|
||||||
if ($this->since) {
|
|
||||||
throw new ServerException("since parameter is disabled for performance; use since_id", 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||||
|
|
||||||
$notice = $this->user->getNotices(
|
$notice = $this->user->getNotices(
|
||||||
($this->page-1) * $this->count, $this->count,
|
($this->page-1) * $this->count, $this->count,
|
||||||
$this->since_id, $this->max_id, $this->since
|
$this->since_id, $this->max_id
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Fave extends Memcached_DataObject
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since)
|
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$fav = new Fave();
|
$fav = new Fave();
|
||||||
$qry = null;
|
$qry = null;
|
||||||
|
@ -100,10 +100,6 @@ class Fave extends Memcached_DataObject
|
||||||
$qry .= 'AND notice_id <= ' . $max_id . ' ';
|
$qry .= 'AND notice_id <= ' . $max_id . ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$qry .= 'AND modified > \'' . date('Y-m-d H:i:s', $since) . '\' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: we sort by fave time, not by notice time!
|
// NOTE: we sort by fave time, not by notice time!
|
||||||
|
|
||||||
$qry .= 'ORDER BY modified DESC ';
|
$qry .= 'ORDER BY modified DESC ';
|
||||||
|
|
|
@ -137,7 +137,7 @@ class Inbox extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false)
|
function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false)
|
||||||
{
|
{
|
||||||
$inbox = Inbox::staticGet('user_id', $user_id);
|
$inbox = Inbox::staticGet('user_id', $user_id);
|
||||||
|
|
||||||
|
@ -195,15 +195,15 @@ class Inbox extends Memcached_DataObject
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param mixed $since_id return only notices after but not including this id
|
* @param mixed $since_id return only notices after but not including this id
|
||||||
* @param mixed $max_id return only notices up to and including this id
|
* @param mixed $max_id return only notices up to and including this id
|
||||||
* @param mixed $since obsolete/ignored
|
|
||||||
* @param mixed $own ignored?
|
* @param mixed $own ignored?
|
||||||
* @return array of Notice objects
|
* @return array of Notice objects
|
||||||
*
|
*
|
||||||
* @todo consider repacking the inbox when this happens?
|
* @todo consider repacking the inbox when this happens?
|
||||||
|
* @fixme reimplement $own if we need it?
|
||||||
*/
|
*/
|
||||||
function streamNotices($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false)
|
function streamNotices($user_id, $offset, $limit, $since_id, $max_id, $own=false)
|
||||||
{
|
{
|
||||||
$ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $since, $own);
|
$ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $own);
|
||||||
|
|
||||||
// Do a bulk lookup for the first $limit items
|
// Do a bulk lookup for the first $limit items
|
||||||
// Fast path when nothing's deleted.
|
// Fast path when nothing's deleted.
|
||||||
|
|
|
@ -559,17 +559,17 @@ class Notice extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null)
|
function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$ids = Notice::stream(array('Notice', '_publicStreamDirect'),
|
$ids = Notice::stream(array('Notice', '_publicStreamDirect'),
|
||||||
array(),
|
array(),
|
||||||
'public',
|
'public',
|
||||||
$offset, $limit, $since_id, $max_id, $since);
|
$offset, $limit, $since_id, $max_id);
|
||||||
|
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null)
|
function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
|
@ -598,10 +598,6 @@ class Notice extends Memcached_DataObject
|
||||||
$notice->whereAdd('id <= ' . $max_id);
|
$notice->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
if ($notice->find()) {
|
if ($notice->find()) {
|
||||||
|
@ -616,17 +612,17 @@ class Notice extends Memcached_DataObject
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null)
|
function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$ids = Notice::stream(array('Notice', '_conversationStreamDirect'),
|
$ids = Notice::stream(array('Notice', '_conversationStreamDirect'),
|
||||||
array($id),
|
array($id),
|
||||||
'notice:conversation_ids:'.$id,
|
'notice:conversation_ids:'.$id,
|
||||||
$offset, $limit, $since_id, $max_id, $since);
|
$offset, $limit, $since_id, $max_id);
|
||||||
|
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _conversationStreamDirect($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null)
|
function _conversationStreamDirect($id, $offset=0, $limit=20, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
|
@ -649,10 +645,6 @@ class Notice extends Memcached_DataObject
|
||||||
$notice->whereAdd('id <= ' . $max_id);
|
$notice->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
if ($notice->find()) {
|
if ($notice->find()) {
|
||||||
|
@ -1270,16 +1262,16 @@ class Notice extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null)
|
function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$cache = common_memcache();
|
$cache = common_memcache();
|
||||||
|
|
||||||
if (empty($cache) ||
|
if (empty($cache) ||
|
||||||
$since_id != 0 || $max_id != 0 || (!is_null($since) && $since > 0) ||
|
$since_id != 0 || $max_id != 0 ||
|
||||||
is_null($limit) ||
|
is_null($limit) ||
|
||||||
($offset + $limit) > NOTICE_CACHE_WINDOW) {
|
($offset + $limit) > NOTICE_CACHE_WINDOW) {
|
||||||
return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id,
|
return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id,
|
||||||
$max_id, $since)));
|
$max_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$idkey = common_cache_key($cachekey);
|
$idkey = common_cache_key($cachekey);
|
||||||
|
|
|
@ -49,12 +49,12 @@ class Notice_inbox extends Memcached_DataObject
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
function stream($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false)
|
function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false)
|
||||||
{
|
{
|
||||||
throw new Exception('Notice_inbox no longer used; use Inbox');
|
throw new Exception('Notice_inbox no longer used; use Inbox');
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since)
|
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
throw new Exception('Notice_inbox no longer used; use Inbox');
|
throw new Exception('Notice_inbox no longer used; use Inbox');
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Notice_tag extends Memcached_DataObject
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($tag, $offset, $limit, $since_id, $max_id, $since)
|
function _streamDirect($tag, $offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$nt = new Notice_tag();
|
$nt = new Notice_tag();
|
||||||
|
|
||||||
|
@ -63,10 +63,6 @@ class Notice_tag extends Memcached_DataObject
|
||||||
$nt->whereAdd('notice_id < ' . $max_id);
|
$nt->whereAdd('notice_id < ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$nt->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$nt->orderBy('notice_id DESC');
|
$nt->orderBy('notice_id DESC');
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
|
|
|
@ -163,27 +163,27 @@ class Profile extends Memcached_DataObject
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$ids = Notice::stream(array($this, '_streamTaggedDirect'),
|
$ids = Notice::stream(array($this, '_streamTaggedDirect'),
|
||||||
array($tag),
|
array($tag),
|
||||||
'profile:notice_ids_tagged:' . $this->id . ':' . $tag,
|
'profile:notice_ids_tagged:' . $this->id . ':' . $tag,
|
||||||
$offset, $limit, $since_id, $max_id, $since);
|
$offset, $limit, $since_id, $max_id);
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
|
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
// XXX: I'm not sure this is going to be any faster. It probably isn't.
|
// XXX: I'm not sure this is going to be any faster. It probably isn't.
|
||||||
$ids = Notice::stream(array($this, '_streamDirect'),
|
$ids = Notice::stream(array($this, '_streamDirect'),
|
||||||
array(),
|
array(),
|
||||||
'profile:notice_ids:' . $this->id,
|
'profile:notice_ids:' . $this->id,
|
||||||
$offset, $limit, $since_id, $max_id, $since);
|
$offset, $limit, $since_id, $max_id);
|
||||||
|
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id, $since)
|
function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
// XXX It would be nice to do this without a join
|
// XXX It would be nice to do this without a join
|
||||||
|
|
||||||
|
@ -202,10 +202,6 @@ class Profile extends Memcached_DataObject
|
||||||
$query .= " and id < $max_id";
|
$query .= " and id < $max_id";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$query .= " and created > '" . date('Y-m-d H:i:s', $since) . "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$query .= ' order by id DESC';
|
$query .= ' order by id DESC';
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
|
@ -223,7 +219,7 @@ class Profile extends Memcached_DataObject
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($offset, $limit, $since_id, $max_id, $since = null)
|
function _streamDirect($offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
|
@ -240,10 +236,6 @@ class Profile extends Memcached_DataObject
|
||||||
$notice->whereAdd('id <= ' . $max_id);
|
$notice->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice->orderBy('id DESC');
|
$notice->orderBy('id DESC');
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
|
|
|
@ -22,16 +22,16 @@ class Reply extends Memcached_DataObject
|
||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
|
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$ids = Notice::stream(array('Reply', '_streamDirect'),
|
$ids = Notice::stream(array('Reply', '_streamDirect'),
|
||||||
array($user_id),
|
array($user_id),
|
||||||
'reply:stream:' . $user_id,
|
'reply:stream:' . $user_id,
|
||||||
$offset, $limit, $since_id, $max_id, $since);
|
$offset, $limit, $since_id, $max_id);
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null)
|
function _streamDirect($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$reply = new Reply();
|
$reply = new Reply();
|
||||||
$reply->profile_id = $user_id;
|
$reply->profile_id = $user_id;
|
||||||
|
@ -44,10 +44,6 @@ class Reply extends Memcached_DataObject
|
||||||
$reply->whereAdd('notice_id < ' . $max_id);
|
$reply->whereAdd('notice_id < ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$reply->whereAdd('modified > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$reply->orderBy('notice_id DESC');
|
$reply->orderBy('notice_id DESC');
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
|
|
|
@ -456,28 +456,28 @@ class User extends Memcached_DataObject
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
$ids = Reply::stream($this->id, $offset, $limit, $since_id, $before_id, $since);
|
$ids = Reply::stream($this->id, $offset, $limit, $since_id, $before_id);
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) {
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id, $since);
|
return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return $profile->getNotices($offset, $limit, $since_id, $before_id, $since);
|
return $profile->getNotices($offset, $limit, $since_id, $before_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,24 +487,24 @@ class User extends Memcached_DataObject
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false);
|
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true);
|
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false);
|
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
|
function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true);
|
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowFavesCache()
|
function blowFavesCache()
|
||||||
|
@ -789,7 +789,7 @@ class User extends Memcached_DataObject
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _repeatedByMeDirect($offset, $limit, $since_id, $max_id, $since)
|
function _repeatedByMeDirect($offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
|
@ -813,10 +813,6 @@ class User extends Memcached_DataObject
|
||||||
$notice->whereAdd('id <= ' . $max_id);
|
$notice->whereAdd('id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
if ($notice->find()) {
|
if ($notice->find()) {
|
||||||
|
@ -836,12 +832,12 @@ class User extends Memcached_DataObject
|
||||||
$ids = Notice::stream(array($this, '_repeatsOfMeDirect'),
|
$ids = Notice::stream(array($this, '_repeatsOfMeDirect'),
|
||||||
array(),
|
array(),
|
||||||
'user:repeats_of_me:'.$this->id,
|
'user:repeats_of_me:'.$this->id,
|
||||||
$offset, $limit, $since_id, $max_id, null);
|
$offset, $limit, $since_id, $max_id);
|
||||||
|
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _repeatsOfMeDirect($offset, $limit, $since_id, $max_id, $since)
|
function _repeatsOfMeDirect($offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$qry =
|
$qry =
|
||||||
'SELECT DISTINCT original.id AS id ' .
|
'SELECT DISTINCT original.id AS id ' .
|
||||||
|
@ -856,10 +852,6 @@ class User extends Memcached_DataObject
|
||||||
$qry .= 'AND original.id <= ' . $max_id . ' ';
|
$qry .= 'AND original.id <= ' . $max_id . ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$qry .= 'AND original.modified > \'' . date('Y-m-d H:i:s', $since) . '\' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: we sort by fave time, not by notice time!
|
// NOTE: we sort by fave time, not by notice time!
|
||||||
|
|
||||||
$qry .= 'ORDER BY original.id DESC ';
|
$qry .= 'ORDER BY original.id DESC ';
|
||||||
|
|
|
@ -91,7 +91,7 @@ class User_group extends Memcached_DataObject
|
||||||
return Notice::getStreamByIds($ids);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _streamDirect($offset, $limit, $since_id, $max_id, $since)
|
function _streamDirect($offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
$inbox = new Group_inbox();
|
$inbox = new Group_inbox();
|
||||||
|
|
||||||
|
@ -108,10 +108,6 @@ class User_group extends Memcached_DataObject
|
||||||
$inbox->whereAdd('notice_id <= ' . $max_id);
|
$inbox->whereAdd('notice_id <= ' . $max_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($since)) {
|
|
||||||
$inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
|
|
||||||
}
|
|
||||||
|
|
||||||
$inbox->orderBy('notice_id DESC');
|
$inbox->orderBy('notice_id DESC');
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
|
|
|
@ -63,7 +63,6 @@ class ApiAction extends Action
|
||||||
var $count = null;
|
var $count = null;
|
||||||
var $max_id = null;
|
var $max_id = null;
|
||||||
var $since_id = null;
|
var $since_id = null;
|
||||||
var $since = null;
|
|
||||||
|
|
||||||
var $access = self::READ_ONLY; // read (default) or read-write
|
var $access = self::READ_ONLY; // read (default) or read-write
|
||||||
|
|
||||||
|
@ -85,7 +84,10 @@ class ApiAction extends Action
|
||||||
$this->count = (int)$this->arg('count', 20);
|
$this->count = (int)$this->arg('count', 20);
|
||||||
$this->max_id = (int)$this->arg('max_id', 0);
|
$this->max_id = (int)$this->arg('max_id', 0);
|
||||||
$this->since_id = (int)$this->arg('since_id', 0);
|
$this->since_id = (int)$this->arg('since_id', 0);
|
||||||
$this->since = $this->arg('since');
|
|
||||||
|
if ($this->arg('since')) {
|
||||||
|
$this->clientError(_("since parameter is disabled for performance; use since_id"), 403);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1325,8 +1327,6 @@ class ApiAction extends Action
|
||||||
case 'max_id':
|
case 'max_id':
|
||||||
$max_id = (int)$this->args['max_id'];
|
$max_id = (int)$this->args['max_id'];
|
||||||
return ($max_id < 1) ? 0 : $max_id;
|
return ($max_id < 1) ? 0 : $max_id;
|
||||||
case 'since':
|
|
||||||
return strtotime($this->args['since']);
|
|
||||||
default:
|
default:
|
||||||
return parent::arg($key, $def);
|
return parent::arg($key, $def);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user