From 3328726f6333f9ebf3217b2a62d435717a95629a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 22 Sep 2018 20:41:26 -0600 Subject: [PATCH] Update Discover Controller --- app/Http/Controllers/DiscoverController.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 5c910415e..f991e4f04 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -27,10 +27,12 @@ class DiscoverController extends Controller $pid = Auth::user()->profile->id; - $following = Cache::remember('feature:discover:following:'.$pid, 15, function() use($pid) { - $following = Follower::whereProfileId($pid) - ->pluck('following_id'); - $filtered = UserFilter::whereUserId($pid) + $following = Cache::remember('feature:discover:following:'.$pid, 720, function() use($pid) { + $following = Follower::select('following_id') + ->whereProfileId($pid) + ->pluck('following_id'); + $filtered = UserFilter::select('filterable_id') + ->whereUserId($pid) ->whereFilterableType('App\Profile') ->whereIn('filter_type', ['mute', 'block']) ->pluck('filterable_id'); @@ -43,7 +45,7 @@ class DiscoverController extends Controller }); $people = Cache::remember('feature:discover:people:'.$pid, 15, function() use($following) { - return Profile::inRandomOrder() + return Profile::select('id', 'name', 'username')->inRandomOrder() ->whereHas('statuses') ->whereNull('domain') ->whereNotIn('id', $following) @@ -52,13 +54,14 @@ class DiscoverController extends Controller ->get(); }); - $posts = Status::whereHas('media') + $posts = Status::select('id', 'caption', 'profile_id') + ->whereHas('media') ->whereHas('profile', function($q) { $q->where('is_private', false); }) ->whereIsNsfw(false) ->whereVisibility('public') - ->where('profile_id', '!=', $pid) + ->where('profile_id', '<>', $pid) ->whereNotIn('profile_id', $following) ->withCount(['comments', 'likes']) ->orderBy('created_at', 'desc')