Skip to content

Commit

Permalink
fix(repositories): make db queries use count
Browse files Browse the repository at this point in the history
This should fix /about page
  • Loading branch information
WerySkok committed Dec 10, 2023
1 parent b2b6fe6 commit 88d296a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Web/Models/Repositories/Clubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function find(string $query, array $pars = [], string $sort = "id DESC", int $pa

function getCount(): int
{
return sizeof(clone $this->clubs);
return (clone $this->clubs)->count('*');
}

function getPopularClubs(): \Traversable
Expand Down
2 changes: 1 addition & 1 deletion Web/Models/Repositories/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,6 @@ function getSuggestedPostsCountByUser(int $club, int $user): int

function getCount(): int
{
return sizeof(clone $this->posts);
return (clone $this->posts)->count('*');
}
}
6 changes: 3 additions & 3 deletions Web/Models/Repositories/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ function find(string $query, array $pars = [], string $sort = "id DESC"): Util\E
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('*'),
];
}

Expand Down

0 comments on commit 88d296a

Please sign in to comment.