Update ApiV1Controller, update discoverAccountsPopular method

This commit is contained in:
Daniel Supernault 2023-12-16 06:22:56 -07:00
parent d3f032b2ec
commit 60e053c936
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -3619,25 +3619,31 @@ class ApiV1Controller extends Controller
$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')
->where('is_private', false)
->whereNull('status')
->orderByDesc('profiles.followers_count')
->limit(20)
->limit(30)
->get();
});
$filters = UserFilterService::filters($pid);
$ids = $ids->map(function($profile) {
return AccountService::get($profile->id, true);
})
->filter(function($profile) use($pid) {
return $profile && isset($profile['id']);
return $profile && isset($profile['id'], $profile['locked']) && !$profile['locked'];
})
->filter(function($profile) use($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();
return $this->json($ids);