Skip to content

Commit

Permalink
Move the grouping of the events into the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispelzer committed Nov 20, 2018
1 parent bea1771 commit 3ba0bc2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/Repositories/EventRepository.php
Expand Up @@ -44,17 +44,19 @@ public function getEvents($site_id)
'end_date' => date('Y-m-d', strtotime('+6 month')),
];

$events_listing = $this->cache->remember($params['method'].md5(serialize($params)), config('cache.ttl'), function () use ($params) {
$events['events'] = $this->cache->remember($params['method'].md5(serialize($params)), config('cache.ttl'), function () use ($params) {
$this->wsuApi->nextRequestProduction();

return $this->wsuApi->sendRequest($params['method'], $params);
});
$events_listing = $this->wsuApi->sendRequest($params['method'], $params);

if (!empty($events_listing['events'])) {
$events_listing = collect($events_listing['events'])->groupBy('date')->toArray();
} else {
$events_listing = [];
}

if (!empty($events_listing['events'])) {
$events['events'] = collect($events_listing['events'])->groupBy('date')->toArray();
} else {
$events['events'] = [];
}
return $events_listing;
});

return $events;
}
Expand Down

0 comments on commit 3ba0bc2

Please sign in to comment.