Fixed multiple issues in stathandler / statpage
authorMarcel Werk <burntime@woltlab.com>
Wed, 9 Jul 2014 15:01:25 +0000 (17:01 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 9 Jul 2014 15:01:25 +0000 (17:01 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/stat.tpl
wcfsetup/install/files/lib/data/stat/daily/StatDailyAction.class.php
wcfsetup/install/files/lib/system/worker/StatDailyRebuildDataWorker.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index f0d7ae3949aadcf81716aaa5f5f7e66df01f4553..cbb902846cb2da7a08826b289c6aede20824e807 100644 (file)
@@ -2612,6 +2612,10 @@ WCF.ACP.Stat.Chart = Class.extend({
                                $("#chartTooltip").hide();
                        }
                });
+               
+               if (!$data.length) {
+                       $('#chart').append('<p style="position: absolute; font-size: 1.2rem; text-align: center; top: 50%; margin-top: -20px; width: 100%">' + WCF.Language.get('wcf.acp.stat.noData') + '</p>');
+               }
        }
 });
 
index 71ba2ea6d912fdfa09b90c25d4747b96446a0e89..2b89b22a1569838f962b11fc4febbc4fcc60c92e 100644 (file)
@@ -9,7 +9,8 @@
                        'wcf.acp.stat.timeFormat.daily': '{lang}wcf.acp.stat.timeFormat.daily{/lang}',
                        'wcf.acp.stat.timeFormat.weekly': '{lang}wcf.acp.stat.timeFormat.weekly{/lang}',
                        'wcf.acp.stat.timeFormat.monthly': '{lang}wcf.acp.stat.timeFormat.monthly{/lang}',
-                       'wcf.acp.stat.timeFormat.yearly': '{lang}wcf.acp.stat.timeFormat.yearly{/lang}'
+                       'wcf.acp.stat.timeFormat.yearly': '{lang}wcf.acp.stat.timeFormat.yearly{/lang}',
+                       'wcf.acp.stat.noData': '{lang}wcf.acp.stat.noData{/lang}'
                });
                
                new WCF.ACP.Stat.Chart();
index c523bc5dd47ba6008852f4cba1b3c80bca1d9680..b9cf85ecc897fb7bfecb1f4a28433fffc95d97af 100644 (file)
@@ -62,6 +62,7 @@ class StatDailyAction extends AbstractDatabaseObjectAction {
                $conditionBuilder->add('objectTypeID IN (?)', array($this->parameters['objectTypeIDs']));
                $conditionBuilder->add('date BETWEEN ? AND ?', array($this->parameters['startDate'], $this->parameters['endDate']));
                
+               $limit = 0;
                if ($this->parameters['dateGrouping'] == 'yearly') {
                        $sql = "SELECT          MIN(date) AS date, SUM(counter) AS counter, MAX(total) AS total, objectTypeID
                                FROM            wcf".WCF_N."_stat_daily
@@ -82,15 +83,17 @@ class StatDailyAction extends AbstractDatabaseObjectAction {
                                ".$conditionBuilder."
                                GROUP BY        EXTRACT(YEAR FROM date), EXTRACT(WEEK FROM date), objectTypeID
                                ORDER BY        date";
+                       $limit = 260;
                }
                else {
                        $sql = "SELECT          *
                                FROM            wcf".WCF_N."_stat_daily
                                ".$conditionBuilder."
                                ORDER BY        date";
+                       $limit = 365;
                }
                
-               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement = WCF::getDB()->prepareStatement($sql, $limit);
                $statement->execute($conditionBuilder->getParameters());
                while ($row = $statement->fetchArray()) {
                        $value = $row['counter'];
index 6fd29d720e8086a305f717cb52ecccd045d68a65..c8c23cf75be5925aa5cd55dd19e010f01b64a9c4 100644 (file)
@@ -73,6 +73,8 @@ class StatDailyRebuildDataWorker extends AbstractRebuildDataWorker {
                        $d->add(new \DateInterval('P'.($this->loopCount * $this->limit).'D'));
                }
                for ($i = 0; $i < $this->limit; $i++) {
+                       if ($d->getTimestamp() > TIME_NOW) break;
+                       
                        // get object types
                        foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) {
                                $data = $objectType->getProcessor()->getData($d->getTimestamp());
index bad6fc0b4e0c58bcff7fa127ff5ad6687a022cce..bce4a2a8e5b97052fe0b40f07576defb87868789 100644 (file)
@@ -1237,6 +1237,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></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>
+               <item name="wcf.acp.stat.noData"><![CDATA[Es liegen keine Daten für den ausgewählten Zeitraum vor.]]></item>
        </category>
        
        <category name="wcf.acp.updateServer">
index 1fbf1d3f169e55a25a8e4bf2196fde2338f98d51..99cd1d6de44e3fac340c70061507c09e688656a2 100644 (file)
@@ -1206,6 +1206,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></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>
+               <item name="wcf.acp.stat.noData"><![CDATA[TODO: Es liegen keine Daten für den ausgewählten Zeitraum vor.]]></item>
        </category>
        
        <category name="wcf.acp.updateServer">