<cronjob>
<classname><![CDATA[wcf\system\cronjob\ModerationQueueCronjob]]></classname>
- <description><![CDATA[Moderation Queue Cleanup]]></description>
+ <description><![CDATA[Moderation queue cleanup]]></description>
+ <description language="de"><![CDATA[Löscht veraltete Einträge in der Moderation]]></description>
+ <startminute>0</startminute>
+ <starthour>1</starthour>
+ <startdom>*</startdom>
+ <startmonth>*</startmonth>
+ <startdow>*</startdow>
+ <active>1</active>
+ <canbeedited>1</canbeedited>
+ <canbedisabled>1</canbedisabled>
+ </cronjob>
+
+ <cronjob>
+ <classname><![CDATA[wcf\system\cronjob\StatDailyBuilderCronjob]]></classname>
+ <description><![CDATA[Builds the daily statistics]]></description>
+ <description language="de"><![CDATA[Generiert die täglichen Statistiken]]></description>
<startminute>0</startminute>
<starthour>1</starthour>
<startdom>*</startdom>
<nicevalue>100</nicevalue>
</type>
<!-- /rebuild data workers -->
+
+ <!-- stat handlers -->
+ <type>
+ <name>com.woltlab.wcf.user</name>
+ <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
+ <classname><![CDATA[wcf\system\stat\UserStatDailyHandler]]></classname>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.attachment</name>
+ <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
+ <classname><![CDATA[wcf\system\stat\AttachmentStatDailyHandler]]></classname>
+ </type>
+ <!-- /stat handlers -->
</import>
</data>
\ No newline at end of file
<name>com.woltlab.wcf.rebuildData</name>
<interfacename><![CDATA[wcf\system\worker\IRebuildDataWorker]]></interfacename>
</definition>
+
+ <definition>
+ <name>com.woltlab.wcf.statDailyHandler</name>
+ <interfacename><![CDATA[wcf\system\stat\IStatDailyHandler]]></interfacename>
+ </definition>
</import>
</data>
--- /dev/null
+<?php
+namespace wcf\system\cronjob;
+use wcf\data\cronjob\Cronjob;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\WCF;
+use wcf\util\DateUtil;
+
+/**
+ * Builds daily statistics.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2014 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cronjob
+ * @category Community Framework
+ */
+class StatDailyBuilderCronjob extends AbstractCronjob {
+ /**
+ * @see \wcf\system\cronjob\ICronjob::execute()
+ */
+ public function execute(Cronjob $cronjob) {
+ parent::execute($cronjob);
+
+ // get date
+ $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
+ $d->setTimezone(new \DateTimeZone(TIMEZONE));
+ $d->sub(new \DateInterval('P1D'));
+ $d->setTime(0, 0);
+ $date = $d->getTimestamp();
+
+ // prepare insert statement
+ $sql = "INSERT IGNORE INTO wcf".WCF_N."_stat_daily
+ (objectTypeID, date, counter, total)
+ VALUES (?, ?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ // get object types
+ foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
+ $data = $objectType->getProcessor()->getData($date);
+
+ $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total']));
+ }
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\stat;
+use wcf\system\WCF;
+
+/**
+ * Abstract implementation of a stat handler.
+ *
+ * @author Marcel Werk
+ * @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 AbstractStatDailyHandler implements IStatDailyHandler {
+ /**
+ * Counts the number of rows for a single day.
+ *
+ * @param integer $date
+ * @param string $tableName
+ * @param string $dateColumnName
+ * @return integer
+ */
+ protected function getCounter($date, $tableName, $dateColumnName) {
+ $sql = "SELECT COUNT(*) AS count
+ FROM " . $tableName . "
+ WHERE " . $dateColumnName . " BETWEEN ? AND ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($date, $date + 86400));
+ return $statement->fetchColumn();
+ }
+
+ /**
+ * Counts the total number of rows.
+ *
+ * @param integer $date
+ * @param string $tableName
+ * @param string $dateColumnName
+ * @return integer
+ */
+ protected function getTotal($date, $tableName, $dateColumnName) {
+ $sql = "SELECT COUNT(*) AS count
+ FROM " . $tableName . "
+ WHERE " . $dateColumnName . " < ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($date + 86400));
+ return $statement->fetchColumn();
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\stat;
+use wcf\system\WCF;
+
+/**
+ * Stat handler implementation for attachment stats.
+ *
+ * @author Marcel Werk
+ * @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 AttachmentStatDailyHandler extends AbstractStatDailyHandler {
+ /**
+ * @see \wcf\system\stat\IStatDailyHandler::getData()
+ */
+ public function getData($date) {
+ $sql = "SELECT SUM(filesize)
+ FROM wcf".WCF_N."_attachment
+ WHERE uploadTime BETWEEN ? AND ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($date, $date + 86400));
+ $counter = intval($statement->fetchColumn());
+
+ $sql = "SELECT SUM(filesize)
+ FROM wcf".WCF_N."_attachment
+ WHERE uploadTime < ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($date + 86400));
+ $total = intval($statement->fetchColumn());
+
+ return array(
+ 'counter' => $counter,
+ 'total' => $total
+ );
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\stat;
+
+/**
+ * Provides a general interface for statistic handler.
+ *
+ * @author Marcel Werk
+ * @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
+ */
+interface IStatDailyHandler {
+ /**
+ * Returns the stats.
+ *
+ * @param integer $date
+ * @return array
+ */
+ public function getData($date);
+}
--- /dev/null
+<?php
+namespace wcf\system\stat;
+
+/**
+ * Stat handler implementation for user stats.
+ *
+ * @author Marcel Werk
+ * @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 UserStatDailyHandler extends AbstractStatDailyHandler {
+ /**
+ * @see \wcf\system\stat\IStatDailyHandler::getData()
+ */
+ public function getData($date) {
+ return array(
+ 'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_user', 'registrationDate'),
+ 'total' => $this->getTotal($date, 'wcf'.WCF_N.'_user', 'registrationDate')
+ );
+ }
+}
UNIQUE KEY spiderIdentifier (spiderIdentifier)
);
+DROP TABLE IF EXISTS wcf1_stat_daily;
+CREATE TABLE wcf1_stat_daily (
+ objectTypeID INT(10) NOT NULL,
+ date DATE NOT NULL,
+ counter INT(10) NOT NULL DEFAULT 0,
+ total INT(10) NOT NULL DEFAULT 0,
+
+ UNIQUE KEY (objectTypeID, date)
+);
+
DROP TABLE IF EXISTS wcf1_style;
CREATE TABLE wcf1_style (
styleID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
ALTER TABLE wcf1_tag_to_object ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;
ALTER TABLE wcf1_tag_to_object ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;
+ALTER TABLE wcf1_stat_daily ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;
+
ALTER TABLE wcf1_search_index ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;
ALTER TABLE wcf1_search_index ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE SET NULL;