X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/75a795ab72c19d9f72ec1f77f1f1c46527fbd102..refs/pull/2734/head:/app/Actions/ViewService.php diff --git a/app/Actions/ViewService.php b/app/Actions/ViewService.php index 51a60d96e..a4e620d4b 100644 --- a/app/Actions/ViewService.php +++ b/app/Actions/ViewService.php @@ -65,7 +65,7 @@ class ViewService { $skipCount = $count * $page; $query = $this->permissionService - ->filterRestrictedEntityRelations($this->view, 'views', 'viewable_id', 'viewable_type', $action) + ->filterRestrictedEntityRelations($this->view->newQuery(), 'views', 'viewable_id', 'viewable_type', $action) ->select('*', 'viewable_id', 'viewable_type', DB::raw('SUM(views) as view_count')) ->groupBy('viewable_id', 'viewable_type') ->orderBy('view_count', 'desc'); @@ -96,6 +96,7 @@ class ViewService /** @var Entity $instance */ foreach ($this->entityProvider->all() as $name => $instance) { $items = $instance::visible()->withLastView() + ->having('last_viewed_at', '>', 0) ->orderBy('last_viewed_at', 'desc') ->skip($count * ($page - 1)) ->take($count)