1
0
Fork 0
forked from mirror/pixelfed

Update Discover Controller

This commit is contained in:
Daniel Supernault 2018-09-22 20:41:26 -06:00
parent 02898ce679
commit 3328726f63
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -27,10 +27,12 @@ class DiscoverController extends Controller
$pid = Auth::user()->profile->id; $pid = Auth::user()->profile->id;
$following = Cache::remember('feature:discover:following:'.$pid, 15, function() use($pid) { $following = Cache::remember('feature:discover:following:'.$pid, 720, function() use($pid) {
$following = Follower::whereProfileId($pid) $following = Follower::select('following_id')
->pluck('following_id'); ->whereProfileId($pid)
$filtered = UserFilter::whereUserId($pid) ->pluck('following_id');
$filtered = UserFilter::select('filterable_id')
->whereUserId($pid)
->whereFilterableType('App\Profile') ->whereFilterableType('App\Profile')
->whereIn('filter_type', ['mute', 'block']) ->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id'); ->pluck('filterable_id');
@ -43,7 +45,7 @@ class DiscoverController extends Controller
}); });
$people = Cache::remember('feature:discover:people:'.$pid, 15, function() use($following) { $people = Cache::remember('feature:discover:people:'.$pid, 15, function() use($following) {
return Profile::inRandomOrder() return Profile::select('id', 'name', 'username')->inRandomOrder()
->whereHas('statuses') ->whereHas('statuses')
->whereNull('domain') ->whereNull('domain')
->whereNotIn('id', $following) ->whereNotIn('id', $following)
@ -52,13 +54,14 @@ class DiscoverController extends Controller
->get(); ->get();
}); });
$posts = Status::whereHas('media') $posts = Status::select('id', 'caption', 'profile_id')
->whereHas('media')
->whereHas('profile', function($q) { ->whereHas('profile', function($q) {
$q->where('is_private', false); $q->where('is_private', false);
}) })
->whereIsNsfw(false) ->whereIsNsfw(false)
->whereVisibility('public') ->whereVisibility('public')
->where('profile_id', '!=', $pid) ->where('profile_id', '<>', $pid)
->whereNotIn('profile_id', $following) ->whereNotIn('profile_id', $following)
->withCount(['comments', 'likes']) ->withCount(['comments', 'likes'])
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')