Skip to content

Commit

Permalink
fix(galleries): make some queries more efficient (#1098)
Browse files Browse the repository at this point in the history
* Update GalleryController.php

* Update gallery.blade.php
  • Loading branch information
AW0005 authored Oct 29, 2024
1 parent 79397de commit 9675699
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/GalleryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getGallery($id, Request $request) {
return view('galleries.gallery', [
'gallery' => $gallery,
'submissions' => $query->paginate(20)->appends($request->query()),
'prompts' => [0 => 'Any Prompt'] + Prompt::whereIn('id', GallerySubmission::where('gallery_id', $gallery->id)->visible(Auth::check() ? Auth::user() : null)->accepted()->whereNotNull('prompt_id')->pluck('prompt_id')->toArray())->orderBy('name')->pluck('name', 'id')->toArray(),
'prompts' => [0 => 'Any Prompt'] + Prompt::whereIn('id', GallerySubmission::where('gallery_id', $gallery->id)->visible(Auth::check() ? Auth::user() : null)->accepted()->whereNotNull('prompt_id')->select('prompt_id')->distinct()->pluck('prompt_id')->toArray())->orderBy('name')->pluck('name', 'id')->toArray(),
'childSubmissions' => GallerySubmission::whereIn('gallery_id', $gallery->children->pluck('id')->toArray())->where('is_visible', 1)->where('status', 'Accepted'),
'galleryPage' => true,
'sideGallery' => $gallery,
Expand Down
4 changes: 2 additions & 2 deletions resources/views/galleries/gallery.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</p>
@endif
<p>{!! $gallery->description !!}</p>
@if (!$gallery->submissions->count() && $gallery->children->count() && $childSubmissions->count())
@if (!$gallery->submissions()->count() && $gallery->children->count() && $childSubmissions->count())
<p>This gallery has no submissions; instead, displayed is a selection of the most recent submissions from its sub-galleries. Please navigate to one of the sub-galleries to view more.</p>
@endif

Expand Down Expand Up @@ -59,7 +59,7 @@
{!! Form::close() !!}
</div>

@if ($gallery->submissions->count())
@if ($gallery->submissions()->count())
{!! $submissions->render() !!}

<div class="d-flex align-content-around flex-wrap mb-2">
Expand Down

0 comments on commit 9675699

Please sign in to comment.