We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 2f175156 authored by Evan Prodromou's avatar Evan Prodromou

pre-fill repeats of notices

parent d3399e93
......@@ -581,7 +581,9 @@ class Notice extends Memcached_DataObject
self::blow('conversation::notice_count:%d', $this->conversation);
if (!empty($this->repeat_of)) {
// XXX: we should probably only use one of these
$this->blowStream('notice:repeats:%d', $this->repeat_of);
self::blow('notice:list-ids:repeat_of:%d', $this->repeat_of);
}
$original = Notice::staticGet('id', $this->repeat_of);
......@@ -2432,7 +2434,7 @@ class Notice extends Memcached_DataObject
function __sleep()
{
$vars = parent::__sleep();
$skip = array('_original', '_profile', '_groups', '_attachments', '_faves', '_replies');
$skip = array('_original', '_profile', '_groups', '_attachments', '_faves', '_replies', '_repeats');
return array_diff($vars, $skip);
}
......@@ -2597,4 +2599,30 @@ class Notice extends Memcached_DataObject
$notice->_setReplies($ids);
}
}
protected $_repeats;
function getRepeats()
{
if (isset($this->_repeats) && is_array($this->_repeats)) {
return $this->_repeats;
}
$repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', array($this->id));
$this->_repeats = $repeatMap[$this->id];
return $this->_repeats;
}
function _setRepeats(&$repeats)
{
$this->_repeats = $repeats;
}
static function fillRepeats(&$notices)
{
$ids = self::_idsOf($notices);
$repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', $ids);
foreach ($notices as $notice) {
$notice->_setRepeats($repeatMap[$notice->id]);
}
}
}
......@@ -128,6 +128,8 @@ class NoticeList extends Widget
Notice::fillAttachments($notices);
// Prefill attachments
Notice::fillFaves($notices);
// Prefill repeat data
Notice::fillRepeats($notices);
// Prefill the profiles
$profiles = Notice::fillProfiles($notices);
// Prefill the avatars
......@@ -135,13 +137,14 @@ class NoticeList extends Widget
$p = Profile::current();
$ids = array();
if (!empty($p)) {
$ids = array();
foreach ($notices as $notice) {
$ids[] = $notice->id;
}
foreach ($notices as $notice) {
$ids[] = $notice->id;
}
if (!empty($p)) {
Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id));
Memcached_DataObject::pivotGet('Notice', 'repeat_of', $ids, array('profile_id' => $p->id));
}
......
......@@ -559,12 +559,14 @@ class ThreadedNoticeListRepeatsItem extends NoticeListActorsItem
{
function getProfiles()
{
$rep = $this->notice->repeatStream();
$repeats = $this->notice->getRepeats();
$profiles = array();
while ($rep->fetch()) {
foreach ($repeats as $rep) {
$profiles[] = $rep->profile_id;
}
return $profiles;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment