From 3ca9e85ce4f0db7f160f9a8e989bec898bfbbf55 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 25 Jun 2009 09:43:30 -0700 Subject: update conversations to use newer query format --- classes/Notice.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index 59ffef91a..44179b254 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -346,7 +346,7 @@ class Notice extends Memcached_DataObject { $cache = common_memcache(); if ($cache) { - $ck = 'notice:conversation:'.$this->conversation; + $ck = 'notice:conversation_ids:'.$this->conversation; $cache->delete($ck); if ($blowLast) { $cache->delete($ck.';last'); @@ -762,6 +762,57 @@ class Notice extends Memcached_DataObject return $ids; } + function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + { + $ids = Notice::stream(array('Notice', '_conversationStreamDirect'), + array($id), + 'notice:conversation_ids:'.$id, + $offset, $limit, $since_id, $max_id, $since); + + return Notice::getStreamByIds($ids); + } + + function _conversationStreamDirect($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + { + $notice = new Notice(); + + $notice->selectAdd(); // clears it + $notice->selectAdd('id'); + + $notice->whereAdd('conversation = '.$id); + + $notice->orderBy('id DESC'); + + if (!is_null($offset)) { + $notice->limit($offset, $limit); + } + + if ($since_id != 0) { + $notice->whereAdd('id > ' . $since_id); + } + + if ($max_id != 0) { + $notice->whereAdd('id <= ' . $max_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() { $enabled = common_config('inboxes', 'enabled'); -- cgit v1.2.3-54-g00ecf