From b1fb329fc769788ce67356fdf9b6764043f63b6f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 23 Dec 2013 16:43:06 +0100 Subject: [PATCH] Fixed silly bug Statistics for each user in user list showed comment count instead of post count. --- src/Models/Entities/UserEntity.php | 9 +++++++++ src/Views/user-list.phtml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Models/Entities/UserEntity.php b/src/Models/Entities/UserEntity.php index 9820b631..82666a71 100644 --- a/src/Models/Entities/UserEntity.php +++ b/src/Models/Entities/UserEntity.php @@ -148,4 +148,13 @@ class UserEntity extends AbstractEntity ->where('commenter_id = ?')->put($this->id); return Database::fetchOne($sqlQuery)['count']; } + + public function getPostCount() + { + $sqlQuery = (new SqlQuery) + ->select('count(1)')->as('count') + ->from('post') + ->where('uploader_id = ?')->put($this->id); + return Database::fetchOne($sqlQuery)['count']; + } } diff --git a/src/Views/user-list.phtml b/src/Views/user-list.phtml index b6b4e7ec..b7f90245 100644 --- a/src/Views/user-list.phtml +++ b/src/Views/user-list.phtml @@ -43,7 +43,7 @@
Date registered: joinDate) ?>
Favorite count: getFavoriteCount() ?>
-
Post count: getCommentCount() ?>
+
Post count: getPostCount() ?>