forked from GNUsocial/gnu-social
cache the notice count for threaded view
This commit is contained in:
parent
68b1c05705
commit
59d0e2f373
@ -74,4 +74,23 @@ class Conversation extends Memcached_DataObject
|
||||
|
||||
return $conv;
|
||||
}
|
||||
|
||||
static function noticeCount($id)
|
||||
{
|
||||
$keypart = sprintf('conversation:notice_count:%d', $id);
|
||||
|
||||
$cnt = self::cacheGet($keypart);
|
||||
|
||||
if ($cnt !== false) {
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
$notice = new Notice();
|
||||
$notice->conversation = $id;
|
||||
$cnt = $notice->count();
|
||||
|
||||
self::cacheSet($keypart, $cnt);
|
||||
|
||||
return $cnt;
|
||||
}
|
||||
}
|
||||
|
@ -567,6 +567,7 @@ class Notice extends Memcached_DataObject
|
||||
// was not the root of the conversation. What to do now?
|
||||
|
||||
self::blow('notice:conversation_ids:%d', $this->conversation);
|
||||
self::blow('conversation::notice_count:%d', $this->conversation);
|
||||
|
||||
if (!empty($this->repeat_of)) {
|
||||
self::blow('notice:repeats:%d', $this->repeat_of);
|
||||
|
@ -284,9 +284,8 @@ class ThreadedNoticeListMoreItem extends NoticeListItem
|
||||
$id = $this->notice->conversation;
|
||||
$url = common_local_url('conversationreplies', array('id' => $id));
|
||||
|
||||
$notice = new Notice();
|
||||
$notice->conversation = $id;
|
||||
$n = $notice->count() - 1;
|
||||
$n = Conversation::noticeCount($id) - 1;
|
||||
|
||||
// TRANS: Link to show replies for a notice.
|
||||
// TRANS: %d is the number of replies to a notice and used for plural.
|
||||
$msg = sprintf(_m('Show reply', 'Show all %d replies', $n), $n);
|
||||
|
Loading…
Reference in New Issue
Block a user