From f5f3032ec34beeb1371d3f1996d042e489dcf172 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 8 Jul 2014 21:24:51 +0200 Subject: [PATCH] Add comment stat handler implementation --- com.woltlab.wcf/objectType.xml | 10 ++- .../AbstractCommentStatDailyHandler.class.php | 84 +++++++++++++++++++ ...erProfileCommentStatDailyHandler.class.php | 19 +++++ wcfsetup/install/lang/de.xml | 2 + wcfsetup/install/lang/en.xml | 2 + 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php create mode 100644 wcfsetup/install/files/lib/system/stat/UserProfileCommentStatDailyHandler.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index be8a7221f0..567794498b 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -357,13 +357,19 @@ com.woltlab.wcf.like com.woltlab.wcf.statDailyHandler - com.woltlab.wcf.general + com.woltlab.wcf.user com.woltlab.wcf.dislike com.woltlab.wcf.statDailyHandler - com.woltlab.wcf.general + com.woltlab.wcf.user + + + com.woltlab.wcf.userProfileComment + com.woltlab.wcf.statDailyHandler + + com.woltlab.wcf.user diff --git a/wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php new file mode 100644 index 0000000000..7131a22a77 --- /dev/null +++ b/wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php @@ -0,0 +1,84 @@ + + * @package com.woltlab.wcf + * @subpackage system.stat + * @category Community Framework + */ +abstract class AbstractCommentStatDailyHandler extends AbstractStatDailyHandler { + /** + * name of the comment object type + * @var string + */ + protected $objectType = ''; + + /** + * @see \wcf\system\stat\IStatDailyHandler::getData() + */ + public function getData($date) { + $objectTypeID = CommentHandler::getInstance()->getObjectTypeID($this->objectType); + if ($objectTypeID === null) { + throw new SystemException("Unknown comment object type '".$this->objectType."'"); + } + + $sql = "SELECT ( + SELECT COUNT(*) + FROM wcf".WCF_N."_comment + WHERE objectTypeID = ? + AND time BETWEEN ? AND ? + ) + ( + SELECT COUNT(*) + FROM wcf".WCF_N."_comment_response comment_response + LEFT JOIN wcf".WCF_N."_comment comment + ON (comment.commentID = comment_response.commentID) + WHERE comment.objectTypeID = ? + AND comment_response.time BETWEEN ? AND ? + )"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $objectTypeID, + $date, + $date + 86399, + $objectTypeID, + $date, + $date + 86399 + )); + $counter = $statement->fetchColumn(); + + $sql = "SELECT ( + SELECT COUNT(*) + FROM wcf".WCF_N."_comment + WHERE objectTypeID = ? + AND time < ? + ) + ( + SELECT COUNT(*) + FROM wcf".WCF_N."_comment_response comment_response + LEFT JOIN wcf".WCF_N."_comment comment + ON (comment.commentID = comment_response.commentID) + WHERE comment.objectTypeID = ? + AND comment_response.time < ? + )"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $objectTypeID, + $date + 86400, + $objectTypeID, + $date + 86400 + )); + $total = $statement->fetchColumn(); + + return array( + 'counter' => $counter, + 'total' => $total + ); + } +} diff --git a/wcfsetup/install/files/lib/system/stat/UserProfileCommentStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/UserProfileCommentStatDailyHandler.class.php new file mode 100644 index 0000000000..0353b54f1f --- /dev/null +++ b/wcfsetup/install/files/lib/system/stat/UserProfileCommentStatDailyHandler.class.php @@ -0,0 +1,19 @@ + + * @package com.woltlab.wcf + * @subpackage system.stat + * @category Community Framework + */ +class UserProfileCommentStatDailyHandler extends AbstractCommentStatDailyHandler { + /** + * @see \wcf\system\stat\AbstractCommentStatDailyHandler::$objectType + */ + protected $objectType = 'com.woltlab.wcf.user.profileComment'; +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 5295415872..dbe7983497 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1229,12 +1229,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 1585a523bc..f2ba66838b 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1198,12 +1198,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + + -- 2.20.1