Add caching for events
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
3ec9149d75
commit
6f268a224b
|
@ -149,8 +149,9 @@ abstract class EventManager extends ComponentBase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->eventMeta = data_get(app(FetchAllEvents::class)->run(), 'meta', []);
|
$eventData = app(FetchAllEvents::class)->run();
|
||||||
$this->events = $this->page['events'] = collect(app(FetchAllEvents::class)->run()['data']);
|
$this->eventMeta = data_get($eventData, 'meta', []);
|
||||||
|
$this->events = $this->page['events'] = collect($eventData['data']);
|
||||||
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
|
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
|
||||||
$this->currentUrl = url()->current();
|
$this->currentUrl = url()->current();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@
|
||||||
namespace Silva\Adrema\Support;
|
namespace Silva\Adrema\Support;
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Cache;
|
||||||
|
|
||||||
class FetchAllEvents
|
class FetchAllEvents
|
||||||
{
|
{
|
||||||
public function run(): ?Collection
|
public function run(): ?Collection
|
||||||
{
|
{
|
||||||
$events = app(Proxy::class)->run('/api/form');
|
$events = Cache::remember('adrema-all-events', 3600, function () {
|
||||||
|
return app(Proxy::class)->run('/api/form');
|
||||||
|
});
|
||||||
|
|
||||||
if (!$events) {
|
if (!$events) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue