mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 01:33:16 +00:00
Update ApiV1Controller, update discoverAccountsPopular method
This commit is contained in:
parent
d3f032b2ec
commit
60e053c936
1 changed files with 11 additions and 5 deletions
|
@ -3619,25 +3619,31 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
|
|
||||||
$ids = Cache::remember('api:v1.1:discover:accounts:popular', 86400, function() {
|
$ids = Cache::remember('api:v1.1:discover:accounts:popular', 3600, function() {
|
||||||
return DB::table('profiles')
|
return DB::table('profiles')
|
||||||
->where('is_private', false)
|
->where('is_private', false)
|
||||||
->whereNull('status')
|
->whereNull('status')
|
||||||
->orderByDesc('profiles.followers_count')
|
->orderByDesc('profiles.followers_count')
|
||||||
->limit(20)
|
->limit(30)
|
||||||
->get();
|
->get();
|
||||||
});
|
});
|
||||||
|
$filters = UserFilterService::filters($pid);
|
||||||
$ids = $ids->map(function($profile) {
|
$ids = $ids->map(function($profile) {
|
||||||
return AccountService::get($profile->id, true);
|
return AccountService::get($profile->id, true);
|
||||||
})
|
})
|
||||||
->filter(function($profile) use($pid) {
|
->filter(function($profile) use($pid) {
|
||||||
return $profile && isset($profile['id']);
|
return $profile && isset($profile['id'], $profile['locked']) && !$profile['locked'];
|
||||||
})
|
})
|
||||||
->filter(function($profile) use($pid) {
|
->filter(function($profile) use($pid) {
|
||||||
return $profile['id'] != $pid;
|
return $profile['id'] != $pid;
|
||||||
})
|
})
|
||||||
->take(6)
|
->filter(function($profile) use($pid) {
|
||||||
|
return !FollowerService::follows($pid, $profile['id'], true);
|
||||||
|
})
|
||||||
|
->filter(function($profile) use($filters) {
|
||||||
|
return !in_array($profile['id'], $filters);
|
||||||
|
})
|
||||||
|
->take(16)
|
||||||
->values();
|
->values();
|
||||||
|
|
||||||
return $this->json($ids);
|
return $this->json($ids);
|
||||||
|
|
Loading…
Reference in a new issue