mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
EventPresentationModel: Cache the result of getBundledEvents()
Change-Id: I83ce3b7754055dd494fcde41f043144294da2f3f
This commit is contained in:
parent
5be28ba4df
commit
104075d2d4
|
@ -27,6 +27,11 @@ abstract class EchoEventPresentationModel {
|
|||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @var EchoEvent[]|null
|
||||
*/
|
||||
private $bundledEvents;
|
||||
|
||||
/**
|
||||
* @param EchoEvent $event
|
||||
* @param Language|string $language
|
||||
|
@ -88,17 +93,20 @@ abstract class EchoEventPresentationModel {
|
|||
if ( !$this->event->getBundleHash() ) {
|
||||
return array();
|
||||
}
|
||||
if ( $this->bundledEvents !== null ) {
|
||||
return $this->bundledEvents;
|
||||
}
|
||||
|
||||
// FIXME: We really shouldn't be making db queries like this
|
||||
// in the presentation model
|
||||
$eventMapper = new EchoEventMapper();
|
||||
$events = $eventMapper->fetchByUserBundleHash(
|
||||
$this->bundledEvents = $eventMapper->fetchByUserBundleHash(
|
||||
$this->user,
|
||||
$this->event->getBundleHash()
|
||||
// default params: web, DESC, limit=250
|
||||
);
|
||||
|
||||
return $events;
|
||||
return $this->bundledEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue