Add comment stat handler implementation
authorMatthias Schmidt <gravatronics@live.com>
Tue, 8 Jul 2014 19:24:51 +0000 (21:24 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 8 Jul 2014 19:24:51 +0000 (21:24 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/stat/AbstractCommentStatDailyHandler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/stat/UserProfileCommentStatDailyHandler.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index be8a7221f054f2a977eb1c546aac28097eeeb5ca..567794498b9f567e27f30cac5a265fe72caca6c8 100644 (file)
                        <name>com.woltlab.wcf.like</name>
                        <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
                        <classname><![CDATA[wcf\system\stat\LikeStatDailyHandler]]></classname>
-                       <categoryname>com.woltlab.wcf.general</categoryname>
+                       <categoryname>com.woltlab.wcf.user</categoryname>
                </type>
                <type>
                        <name>com.woltlab.wcf.dislike</name>
                        <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
                        <classname><![CDATA[wcf\system\stat\DislikeStatDailyHandler]]></classname>
-                       <categoryname>com.woltlab.wcf.general</categoryname>
+                       <categoryname>com.woltlab.wcf.user</categoryname>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.userProfileComment</name>
+                       <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
+                       <classname><![CDATA[wcf\system\stat\UserProfileCommentStatDailyHandler]]></classname>
+                       <categoryname>com.woltlab.wcf.user</categoryname>
                </type>
                <!-- /stat handlers -->
                
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 (file)
index 0000000..7131a22
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+namespace wcf\system\stat;
+use wcf\system\comment\CommentHandler;
+use wcf\system\exception\SystemException;
+use wcf\system\WCF;
+
+/**
+ * Abstract implementation of a comment stat handler.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2014 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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 (file)
index 0000000..0353b54
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+namespace wcf\system\stat;
+
+/**
+ * Stat handler implementation for user profile comments.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2014 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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';
+}
index 52954158722d9a07e778f120e359f732a3eb6732..dbe7983497b5028380cc9866ac721de215ccfeee 100644 (file)
@@ -1229,12 +1229,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.attachment.diskUsage"><![CDATA[Dateianhänge-Speicherbedarf (MB)]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.like"><![CDATA[Likes]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.dislike"><![CDATA[Dislikes]]></item>
+               <item name="wcf.acp.stat.com.woltlab.wcf.userProfileComment"><![CDATA[Benutzerprofil-Pinnwand]]></item>
                <item name="wcf.acp.stat.dateGrouping"><![CDATA[Zeiteinheit]]></item>
                <item name="wcf.acp.stat.dateGrouping.daily"><![CDATA[Tag]]></item>
                <item name="wcf.acp.stat.dateGrouping.weekly"><![CDATA[Woche]]></item>
                <item name="wcf.acp.stat.dateGrouping.monthly"><![CDATA[Monat]]></item>
                <item name="wcf.acp.stat.dateGrouping.yearly"><![CDATA[Jahr]]></item>
                <item name="wcf.acp.stat.category.com.woltlab.wcf.general"><![CDATA[Allgemeine Daten]]></item>
+               <item name="wcf.acp.stat.category.com.woltlab.wcf.user"><![CDATA[Benutzer-Daten]]></item>
        </category>
        
        <category name="wcf.acp.updateServer">
index 1585a523bcce059f924416561c6833347f905459..f2ba66838b3fa426396438d1a16f1528c52d4e57 100644 (file)
@@ -1198,12 +1198,14 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.attachment.diskUsage"><![CDATA[TODO: Dateianhänge-Speicherbedarf (MB)]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.like"><![CDATA[Likes]]></item>
                <item name="wcf.acp.stat.com.woltlab.wcf.dislike"><![CDATA[Dislikes]]></item>
+               <item name="wcf.acp.stat.com.woltlab.wcf.userProfileComment"><![CDATA[Wall Comments]]></item>
                <item name="wcf.acp.stat.dateGrouping"><![CDATA[Time Unit]]></item>
                <item name="wcf.acp.stat.dateGrouping.daily"><![CDATA[Day]]></item>
                <item name="wcf.acp.stat.dateGrouping.weekly"><![CDATA[Week]]></item>
                <item name="wcf.acp.stat.dateGrouping.monthly"><![CDATA[Month]]></item>
                <item name="wcf.acp.stat.dateGrouping.yearly"><![CDATA[Year]]></item>
                <item name="wcf.acp.stat.category.com.woltlab.wcf.general"><![CDATA[General Data]]></item>
+               <item name="wcf.acp.stat.category.com.woltlab.wcf.user"><![CDATA[User Data]]></item>
        </category>
        
        <category name="wcf.acp.updateServer">