diff --git a/app/Classes/Bundle.php b/app/Classes/Bundle.php index 9632625..561ff03 100644 --- a/app/Classes/Bundle.php +++ b/app/Classes/Bundle.php @@ -11,7 +11,6 @@ use Exception; use Illuminate\Filesystem\FilesystemAdapter; use Illuminate\Support\Collection; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use League\Flysystem\StorageAttributes; @@ -219,24 +218,14 @@ public function touch() } } - public function render(bool $ignoreCache = false) + public function render() { - $lastModified = Carbon::parse($this->metadata()->get('lastModified', '1970-01-02')); - $lastRendered = Carbon::parse($this->metadata()->get('lastRendered', '1970-01-01')); - $cacheKey = sprintf('render_%s', Str::slug($this->getPath())); - - if ($lastRendered->gt($lastModified) && Cache::has($cacheKey) && !$ignoreCache) { - return Cache::get($cacheKey); - } - $renderer = BundleRenderer::getBundleRendererFor($this); $result = $renderer->render(); $this->metadata()->set('lastRendered', now()->toIso8601String()); $this->metadata()->save(); - Cache::put($cacheKey, $result, now()->addMonth()); - return $result; } @@ -250,7 +239,7 @@ public function renderCard() /** * Return a list of bundles in the specified path */ - public static function findBundles(FilesystemAdapter $disk, ?string $path = '/', bool $recursive = false): array + public static function findBundles(FilesystemAdapter $disk, ?string $path = '/', bool $recursive = false, bool $sortByDate = true): array { $bundles = []; @@ -272,14 +261,16 @@ public static function findBundles(FilesystemAdapter $disk, ?string $path = '/', } } - $bundles = collect($bundles) - ->sortBy([ - fn (Bundle $a, Bundle $b) => Carbon::parse($a->metadata()->get('date')) - ->gt(Carbon::parse($b->metadata()->get('date'))), - fn (Bundle $a, Bundle $b) => Carbon::parse($b->metadata()->get('date')) - ->gt(Carbon::parse($a->metadata()->get('date'))), - ]) - ->toArray(); + if ($sortByDate) { + $bundles = collect($bundles) + ->sortBy([ + fn (Bundle $a, Bundle $b) => Carbon::parse($a->metadata()->get('date')) + ->gt(Carbon::parse($b->metadata()->get('date'))), + fn (Bundle $a, Bundle $b) => Carbon::parse($b->metadata()->get('date')) + ->gt(Carbon::parse($a->metadata()->get('date'))), + ]) + ->toArray(); + } return $bundles; }