From: Matthias Schmidt Date: Wed, 9 Jul 2014 15:40:12 +0000 (+0200) Subject: Add AbstractDiskUsageStatDailyHandler X-Git-Tag: 2.1.0_Alpha_1~596 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=868ac0de1f646db96747b935255e04d2bb0aeaaa;p=GitHub%2FWoltLab%2FWCF.git Add AbstractDiskUsageStatDailyHandler --- diff --git a/wcfsetup/install/files/lib/system/stat/AbstractDiskUsageStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/AbstractDiskUsageStatDailyHandler.class.php new file mode 100644 index 0000000000..5e5c1ab8b4 --- /dev/null +++ b/wcfsetup/install/files/lib/system/stat/AbstractDiskUsageStatDailyHandler.class.php @@ -0,0 +1,46 @@ + + * @package com.woltlab.wcf + * @subpackage system.stat + * @category Community Framework + */ +abstract class AbstractDiskUsageStatDailyHandler extends AbstractStatDailyHandler { + /** + * @see \wcf\system\stat\AbstractStatDailyHandler::getCounter() + */ + protected function getCounter($date, $tableName, $dateColumnName) { + $sql = "SELECT CEIL(SUM(filesize) / 1000) + FROM ".$tableName." + WHERE ".$dateColumnName." BETWEEN ? AND ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($date, $date + 86399)); + return $statement->fetchColumn(); + } + + /** + * @see \wcf\system\stat\AbstractStatDailyHandler::getTotal() + */ + protected function getTotal($date, $tableName, $dateColumnName) { + $sql = "SELECT CEIL(SUM(filesize) / 1000) + FROM ".$tableName." + WHERE ".$dateColumnName." < ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($date + 86400)); + return $statement->fetchColumn(); + } + + /** + * @see \wcf\system\stat\IStatDailyHandler::getFormattedCounter() + */ + public function getFormattedCounter($counter) { + return round($counter / 1000, 2); // return mb + } +} diff --git a/wcfsetup/install/files/lib/system/stat/AttachmentDiskUsageStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/AttachmentDiskUsageStatDailyHandler.class.php index 066300065e..7f12aea4c1 100644 --- a/wcfsetup/install/files/lib/system/stat/AttachmentDiskUsageStatDailyHandler.class.php +++ b/wcfsetup/install/files/lib/system/stat/AttachmentDiskUsageStatDailyHandler.class.php @@ -1,6 +1,5 @@ prepareStatement($sql); - $statement->execute(array($date, $date + 86399)); - $counter = intval($statement->fetchColumn()); - - $sql = "SELECT CEIL(SUM(filesize) / 1000) - 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 + 'counter' => $this->getCounter($date, 'wcf'.WCF_N.'_attachment', 'uploadTime'), + 'total' => $this->getTotal($date, 'wcf'.WCF_N.'_attachment', 'uploadTime') ); } - - /** - * @see \wcf\system\stat\IStatDailyHandler::getFormattedCounter() - */ - public function getFormattedCounter($counter) { - return round($counter / 1000, 2); // return mb - } }