diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-05-27 14:52:35 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-05-27 14:52:35 -0400 |
commit | b3bb8943f592de9f6936f35be49a88c641bf6da1 (patch) | |
tree | befbe8ff6d3c7d1268ecce3696bee5caaa799db7 /classes/Profile.php | |
parent | 698228acb9a6262f2fb4e0c82118249aa94cc0f8 (diff) | |
parent | f59ab5dc40862b141ee5463fd4d24b0d213a96f2 (diff) |
Merge branch '0.7.x' into utf8
Diffstat (limited to 'classes/Profile.php')
-rw-r--r-- | classes/Profile.php | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/classes/Profile.php b/classes/Profile.php index f3bfe299c..ae5641d79 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -155,14 +155,51 @@ class Profile extends Memcached_DataObject function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $qry = - 'SELECT * ' . - 'FROM notice ' . - 'WHERE profile_id = %d '; - - return Notice::getStream(sprintf($qry, $this->id), - 'profile:notices:'.$this->id, - $offset, $limit, $since_id, $before_id); + // 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); + + return Notice::getStreamByIds($ids); + } + + function _streamDirect($offset, $limit, $since_id, $before_id, $since) + { + $notice = new Notice(); + + $notice->profile_id = $this->id; + + $notice->selectAdd(); + $notice->selectAdd('id'); + + if ($since_id != 0) { + $notice->whereAdd('id > ' . $since_id); + } + + if ($before_id != 0) { + $notice->whereAdd('id < ' . $before_id); + } + + if (!is_null($since)) { + $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); + } + + $notice->orderBy('id DESC'); + + if (!is_null($offset)) { + $notice->limit($offset, $limit); + } + + $ids = array(); + + if ($notice->find()) { + while ($notice->fetch()) { + $ids[] = $notice->id; + } + } + + return $ids; } function isMember($group) |