forked from mirror/pixelfed
Update InternalApiController
This commit is contained in:
parent
77569b7e8e
commit
2254ecf27d
|
@ -136,34 +136,31 @@ class InternalApiController extends Controller
|
||||||
});
|
});
|
||||||
$following = array_merge($following, $filters);
|
$following = array_merge($following, $filters);
|
||||||
|
|
||||||
$people = Cache::remember('feature:discover:people:'.$pid, 15, function() use ($following) {
|
$people = Profile::select('id', 'name', 'username')
|
||||||
return Profile::select('id', 'name', 'username')
|
|
||||||
->with('avatar')
|
->with('avatar')
|
||||||
->inRandomOrder()
|
->orderByRaw('rand()')
|
||||||
->whereHas('statuses')
|
->whereHas('statuses')
|
||||||
->whereNull('domain')
|
->whereNull('domain')
|
||||||
->whereNotIn('id', $following)
|
->whereNotIn('id', $following)
|
||||||
->whereIsPrivate(false)
|
->whereIsPrivate(false)
|
||||||
->take(3)
|
->take(3)
|
||||||
->get();
|
->get();
|
||||||
});
|
|
||||||
|
|
||||||
$posts = Cache::remember('feature:discover:posts:'.$pid, 60, function() use ($following) {
|
$posts = Status::select('id', 'caption', 'profile_id')
|
||||||
return Status::select('id', 'caption', 'profile_id')
|
|
||||||
->whereNull('in_reply_to_id')
|
->whereNull('in_reply_to_id')
|
||||||
->whereNull('reblog_of_id')
|
->whereNull('reblog_of_id')
|
||||||
->whereIsNsfw(false)
|
->whereIsNsfw(false)
|
||||||
->whereVisibility('public')
|
->whereVisibility('public')
|
||||||
->whereNotIn('profile_id', $following)
|
->whereNotIn('profile_id', $following)
|
||||||
->withCount(['comments', 'likes'])
|
->with('media')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->take(21)
|
->take(21)
|
||||||
->get();
|
->get();
|
||||||
});
|
|
||||||
|
|
||||||
$res = [
|
$res = [
|
||||||
'people' => $people->map(function($profile) {
|
'people' => $people->map(function($profile) {
|
||||||
return [
|
return [
|
||||||
|
'id' => $profile->id,
|
||||||
'avatar' => $profile->avatarUrl(),
|
'avatar' => $profile->avatarUrl(),
|
||||||
'name' => $profile->name,
|
'name' => $profile->name,
|
||||||
'username' => $profile->username,
|
'username' => $profile->username,
|
||||||
|
@ -174,8 +171,6 @@ class InternalApiController extends Controller
|
||||||
return [
|
return [
|
||||||
'url' => $post->url(),
|
'url' => $post->url(),
|
||||||
'thumb' => $post->thumb(),
|
'thumb' => $post->thumb(),
|
||||||
'comments_count' => $post->comments_count,
|
|
||||||
'likes_count' => $post->likes_count,
|
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue