Update ApiController

This commit is contained in:
Daniel Supernault 2019-04-28 22:22:03 -06:00
parent e4e6f10c90
commit 99503ec464
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -4,8 +4,10 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Api\BaseApiController; use App\Http\Controllers\Api\BaseApiController;
use App\{ use App\{
Follower,
Like, Like,
Profile Profile,
UserFilter
}; };
use Auth; use Auth;
use Cache; use Cache;
@ -58,13 +60,18 @@ class ApiController extends BaseApiController
$id = Auth::user()->profile->id; $id = Auth::user()->profile->id;
$following = Cache::get('profile:following:'.$id, []); $following = Cache::remember('profile:following:'.$id, now()->addHours(12), function() use ($id) {
return Follower::whereProfileId($id)->pluck('following_id')->toArray();
});
array_push($following, $id);
$ids = SuggestionService::get(); $ids = SuggestionService::get();
$filters = UserFilter::whereUserId($id)
->whereFilterableType('App\Profile')
->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id')->toArray();
$following = array_merge($following, $filters);
$res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) { $res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) {
array_push($following, $id);
return Profile::select( return Profile::select(
'id', 'id',
'username' 'username'