Merge pull request #1328 from pixelfed/frontend-ui-refactor

Update DiscoverController
This commit is contained in:
daniel 2019-06-03 13:50:05 -06:00 committed by GitHub
commit 88225a87ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -143,14 +143,17 @@ class DiscoverController extends Controller
abort_if(!config('exp.loops'), 403);
// todo proper pagination, maybe LoopService
$loops = Status::whereType('video')
->whereScope('public')
->latest()
->take(18)
->get();
$res = Cache::remember('discover:loops:recent', now()->addHours(1), function() {
$loops = Status::whereType('video')
->whereScope('public')
->latest()
->take(18)
->get();
$resource = new Fractal\Resource\Collection($loops, new StatusStatelessTransformer());
return $this->fractal->createData($resource)->toArray();
$resource = new Fractal\Resource\Collection($loops, new StatusStatelessTransformer());
return $this->fractal->createData($resource)->toArray();
});
return $res;
}