]> BookStack Code Mirror - bookstack/blobdiff - app/Actions/ViewService.php
Extend /users API endpoint
[bookstack] / app / Actions / ViewService.php
index 51a60d96e20effd49c6eda2ea7f247deb828d6a6..a4e620d4be9dfd2761863bc784a5ef0a798f5f3a 100644 (file)
@@ -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)