mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 08:14:10 +00:00
Update BaseApiController, remove caching
This commit is contained in:
parent
bce8d642ac
commit
f69407e6e4
1 changed files with 7 additions and 11 deletions
|
@ -56,17 +56,13 @@ class BaseApiController extends Controller
|
||||||
public function notifications(Request $request)
|
public function notifications(Request $request)
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
$page = $request->input('page') ?? 1;
|
$timeago = Carbon::now()->subMonths(6);
|
||||||
$res = Cache::remember('profile:notifications:'.$pid.':page:'.$page, now()->addMinutes(5), function() use($pid) {
|
$notifications = Notification::whereProfileId($pid)
|
||||||
$timeago = Carbon::now()->subMonths(6);
|
->whereDate('created_at', '>', $timeago)
|
||||||
$notifications = Notification::whereHas('actor')
|
->orderBy('created_at','desc')
|
||||||
->whereProfileId($pid)
|
->paginate(10);
|
||||||
->whereDate('created_at', '>', $timeago)
|
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
||||||
->orderBy('created_at','desc')
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
->paginate(10);
|
|
||||||
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
|
||||||
return $this->fractal->createData($resource)->toArray();
|
|
||||||
});
|
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue