Add caching for events
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2024-04-26 15:31:32 +02:00
parent 3ec9149d75
commit 6f268a224b
2 changed files with 7 additions and 3 deletions

View File

@ -149,8 +149,9 @@ abstract class EventManager extends ComponentBase
return;
}
$this->eventMeta = data_get(app(FetchAllEvents::class)->run(), 'meta', []);
$this->events = $this->page['events'] = collect(app(FetchAllEvents::class)->run()['data']);
$eventData = app(FetchAllEvents::class)->run();
$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->currentUrl = url()->current();
}

View File

@ -3,12 +3,15 @@
namespace Silva\Adrema\Support;
use Illuminate\Support\Collection;
use Cache;
class FetchAllEvents
{
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) {
return null;