From b6274c969b071941f0a83f2ad2ace3f8c15a5312 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Mar 2019 20:29:51 -0700 Subject: [PATCH] Update DiscoverController --- app/Http/Controllers/DiscoverController.php | 30 ++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 4501535d2..0c87954e0 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -36,15 +36,39 @@ class DiscoverController extends Controller $keyMinutes = 15; $posts = Cache::remember($key, now()->addMinutes($keyMinutes), function() use ($tag, $request) { - return $tag->posts() + $tags = StatusHashtag::select('status_id') + ->whereHashtagId($tag->id) + ->orderByDesc('id') + ->take(48) + ->pluck('status_id'); + + return Status::select( + 'id', + 'uri', + 'caption', + 'rendered', + 'profile_id', + 'type', + 'in_reply_to_id', + 'reblog_of_id', + 'is_nsfw', + 'scope', + 'local', + 'created_at', + 'updated_at' + )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) + ->with('media') + ->whereLocal(true) + ->whereNull('uri') + ->whereIn('id', $tags) + ->whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') ->whereNull('url') ->whereNull('uri') - ->whereHas('media') ->withCount(['likes', 'comments']) ->whereIsNsfw(false) ->whereVisibility('public') ->orderBy('id', 'desc') - ->take(24) ->get(); });