diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-05-29 16:54:24 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-05-29 16:54:24 -0700 |
commit | 425f9d703c5258920079b268c085b0c7112c3b70 (patch) | |
tree | 53b9a2f06accae2bd7fa71e172c09ba4c61793a9 | |
parent | eb76a3bbb36e1f73007cb9b602001ec14f6853c6 (diff) |
Ticket #1567 - Change max_id to return notices <= ID instead of < ID
-rw-r--r-- | actions/twitapidirect_messages.php | 2 | ||||
-rw-r--r-- | classes/Fave.php | 2 | ||||
-rw-r--r-- | classes/Notice.php | 32 | ||||
-rw-r--r-- | classes/Notice_inbox.php | 2 | ||||
-rw-r--r-- | classes/Profile.php | 10 | ||||
-rwxr-xr-x | classes/User_group.php | 2 |
6 files changed, 25 insertions, 25 deletions
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index ab8f07810..d2dbdb619 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -75,7 +75,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction } if ($max_id) { - $message->whereAdd("id < $max_id"); + $message->whereAdd("id <= $max_id"); } if ($since_id) { diff --git a/classes/Fave.php b/classes/Fave.php index cdb479856..572334ce4 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -60,7 +60,7 @@ class Fave extends Memcached_DataObject } if ($max_id != 0) { - $fav->whereAdd('notice_id < ' . $max_id); + $fav->whereAdd('notice_id <= ' . $max_id); } if (!is_null($since)) { diff --git a/classes/Notice.php b/classes/Notice.php index 8dd14b3b7..3f6c5cebb 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -426,22 +426,22 @@ class Notice extends Memcached_DataObject # XXX: too many args; we need to move to named params or even a separate # class for notice streams - static function getStream($qry, $cachekey, $offset=0, $limit=20, $since_id=0, $before_id=0, $order=null, $since=null) { + static function getStream($qry, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0, $order=null, $since=null) { if (common_config('memcached', 'enabled')) { - # Skip the cache if this is a since, since_id or before_id qry - if ($since_id > 0 || $before_id > 0 || $since) { - return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since); + # Skip the cache if this is a since, since_id or max_id qry + if ($since_id > 0 || $max_id > 0 || $since) { + return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $max_id, $order, $since); } else { return Notice::getCachedStream($qry, $cachekey, $offset, $limit, $order); } } - return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since); + return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $max_id, $order, $since); } - static function getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since) { + static function getStreamDirect($qry, $offset, $limit, $since_id, $max_id, $order, $since) { $needAnd = false; $needWhere = true; @@ -463,7 +463,7 @@ class Notice extends Memcached_DataObject $qry .= ' notice.id > ' . $since_id; } - if ($before_id > 0) { + if ($max_id > 0) { if ($needWhere) { $qry .= ' WHERE '; @@ -472,7 +472,7 @@ class Notice extends Memcached_DataObject $qry .= ' AND '; } - $qry .= ' notice.id < ' . $before_id; + $qry .= ' notice.id <= ' . $max_id; } if ($since) { @@ -630,17 +630,17 @@ class Notice extends Memcached_DataObject } } - function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null) + function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) { $ids = Notice::stream(array('Notice', '_publicStreamDirect'), array(), 'public', - $offset, $limit, $since_id, $before_id, $since); + $offset, $limit, $since_id, $max_id, $since); return Notice::getStreamByIds($ids); } - function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null) + function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) { $notice = new Notice(); @@ -664,8 +664,8 @@ class Notice extends Memcached_DataObject $notice->whereAdd('id > ' . $since_id); } - if ($before_id != 0) { - $notice->whereAdd('id < ' . $before_id); + if ($max_id != 0) { + $notice->whereAdd('id <= ' . $max_id); } if (!is_null($since)) { @@ -998,15 +998,15 @@ class Notice extends Memcached_DataObject } } - function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $before_id=0, $since=null) + function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) { $cache = common_memcache(); if (empty($cache) || - $since_id != 0 || $before_id != 0 || !is_null($since) || + $since_id != 0 || $max_id != 0 || !is_null($since) || ($offset + $limit) > NOTICE_CACHE_WINDOW) { return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id, - $before_id, $since))); + $max_id, $since))); } $idkey = common_cache_key($cachekey); diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index 65d7927b7..8a27e1747 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -62,7 +62,7 @@ class Notice_inbox extends Memcached_DataObject } if ($max_id != 0) { - $inbox->whereAdd('notice_id < ' . $max_id); + $inbox->whereAdd('notice_id <= ' . $max_id); } if (!is_null($since)) { diff --git a/classes/Profile.php b/classes/Profile.php index ae5641d79..3d13cd46a 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -153,18 +153,18 @@ class Profile extends Memcached_DataObject return null; } - function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) + 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. $ids = Notice::stream(array($this, '_streamDirect'), array(), 'profile:notice_ids:' . $this->id, - $offset, $limit, $since_id, $before_id); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function _streamDirect($offset, $limit, $since_id, $before_id, $since) + function _streamDirect($offset, $limit, $since_id, $max_id, $since) { $notice = new Notice(); @@ -177,8 +177,8 @@ class Profile extends Memcached_DataObject $notice->whereAdd('id > ' . $since_id); } - if ($before_id != 0) { - $notice->whereAdd('id < ' . $before_id); + if ($max_id != 0) { + $notice->whereAdd('id <= ' . $max_id); } if (!is_null($since)) { diff --git a/classes/User_group.php b/classes/User_group.php index 43591d655..a135015ba 100755 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -72,7 +72,7 @@ class User_group extends Memcached_DataObject } if ($max_id != 0) { - $inbox->whereAdd('notice_id < ' . $max_id); + $inbox->whereAdd('notice_id <= ' . $max_id); } if (!is_null($since)) { |