- $ids = Notice::stream(array($this, '_streamTaggedDirect'),
- array($tag),
- 'profile:notice_ids_tagged:' . $this->id . ':' . $tag,
- $offset, $limit, $since_id, $max_id);
- return Notice::getStreamByIds($ids);
- }
-
- 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, $max_id);
-
- return Notice::getStreamByIds($ids);
- }
-
- function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
- {
- // XXX It would be nice to do this without a join
- // (necessary to do it efficiently on accounts with long history)
-
- $notice = new Notice();
-
- $query =
- "select id from notice join notice_tag on id=notice_id where tag='".
- $notice->escape($tag) .
- "' and profile_id=" . intval($this->id);
-
- $since = Notice::whereSinceId($since_id, 'id', 'notice.created');
- if ($since) {
- $query .= " and ($since)";
- }
-
- $max = Notice::whereMaxId($max_id, 'id', 'notice.created');
- if ($max) {
- $query .= " and ($max)";
- }
-
- $query .= ' order by notice.created DESC, id DESC';
-
- if (!is_null($offset)) {
- $query .= " LIMIT " . intval($limit) . " OFFSET " . intval($offset);
- }
-
- $notice->query($query);