From 88d296a9c49c5975461ccd562cca36b2cfe77b43 Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Sun, 10 Dec 2023 21:55:28 +0300 Subject: [PATCH] fix(repositories): make db queries use count This should fix /about page --- Web/Models/Repositories/Clubs.php | 2 +- Web/Models/Repositories/Posts.php | 2 +- Web/Models/Repositories/Users.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Web/Models/Repositories/Clubs.php b/Web/Models/Repositories/Clubs.php index 04bb30ab..d77eac63 100644 --- a/Web/Models/Repositories/Clubs.php +++ b/Web/Models/Repositories/Clubs.php @@ -53,7 +53,7 @@ class Clubs function getCount(): int { - return sizeof(clone $this->clubs); + return (clone $this->clubs)->count('*'); } function getPopularClubs(): \Traversable diff --git a/Web/Models/Repositories/Posts.php b/Web/Models/Repositories/Posts.php index 89ee58ea..fb32fe6e 100644 --- a/Web/Models/Repositories/Posts.php +++ b/Web/Models/Repositories/Posts.php @@ -252,6 +252,6 @@ class Posts function getCount(): int { - return sizeof(clone $this->posts); + return (clone $this->posts)->count('*'); } } diff --git a/Web/Models/Repositories/Users.php b/Web/Models/Repositories/Users.php index d2f4500e..8e29d866 100644 --- a/Web/Models/Repositories/Users.php +++ b/Web/Models/Repositories/Users.php @@ -142,9 +142,9 @@ class Users function getStatistics(): object { return (object) [ - "all" => sizeof(clone $this->users), - "active" => sizeof((clone $this->users)->where("online > 0")), - "online" => sizeof((clone $this->users)->where("online >= ?", time() - 900)), + "all" => (clone $this->users)->count('*'), + "active" => (clone $this->users)->where("online > 0")->count('*'), + "online" => (clone $this->users)->where("online >= ?", time() - 900)->count('*'), ]; }