success: $.proxy(this._success, this)
});
- $('#statRefreshButton').click($.proxy(this._click, this));
+ $('#statRefreshButton').click($.proxy(this._refresh, this));
- this._click();
+ this._refresh();
},
- _click: function() {
+ _refresh: function() {
var $objectTypeIDs = [ ];
$('input[name=objectTypeID]:checked').each(function() {
$objectTypeIDs.push($(this).val());
});
+ if (!$objectTypeIDs.length) return;
+
this._proxy.setOption('data', {
className: 'wcf\\data\\stat\\daily\\StatDailyAction',
actionName: 'getData',
startDate: $('#startDateDatePicker').val(),
endDate: $('#endDateDatePicker').val(),
value: $('input[name=value]:checked').val(),
+ dateGrouping: $('input[name=dateGrouping]:checked').val(),
objectTypeIDs: $objectTypeIDs
}
});
},
_success: function(data) {
+ switch ($('input[name=dateGrouping]:checked').val()) {
+ case 'yearly':
+ var $minTickSize = [1, "year"];
+ var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.yearly');
+ break;
+ case 'monthly':
+ var $minTickSize = [1, "month"];
+ var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.monthly');
+ break;
+ case 'weekly':
+ var $minTickSize = [7, "day"];
+ var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.weekly');
+ break;
+ default:
+ var $minTickSize = [1, "day"];
+ var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.daily');
+ }
+
var options = {
series: {
lines: {
},
xaxis: {
mode: "time",
- minTickSize: [1, "day"],
- timeformat: WCF.Language.get('wcf.acp.stat.timeFormat')
+ minTickSize: $minTickSize,
+ timeformat: $timeFormat,
+ monthNames: WCF.Language.get('__monthsShort')
},
yaxis: {
min: 0,
$("#chart").on("plothover", function(event, pos, item) {
if (item) {
- $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.addThousandsSeparator(item.datapoint[1]) + ' ' + item.series.label).css({top: item.pageY + 5, left: item.pageX + 5}).wcfFadeIn();
+ $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.formatNumeric(item.datapoint[1]) + ' ' + item.series.label).css({top: item.pageY + 5, left: item.pageX + 5}).wcfFadeIn();
}
else {
$("#chartTooltip").hide();
<script data-relocate="true">
$(function() {
WCF.Language.addObject({
- 'wcf.acp.stat.timeFormat': '{lang}wcf.acp.stat.timeFormat{/lang}'
+ '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}'
});
new WCF.ACP.Stat.Chart();
</dl>
<dl>
- <dt><label for="startDate">{lang}wcf.acp.stat.value{/lang}</label></dt>
+ <dt><label>{lang}wcf.acp.stat.dateGrouping{/lang}</label></dt>
+ <dd>
+ <label><input type="radio" name="dateGrouping" value="daily" checked="checked" /> {lang}wcf.acp.stat.dateGrouping.daily{/lang}</label>
+ <label><input type="radio" name="dateGrouping" value="weekly" /> {lang}wcf.acp.stat.dateGrouping.weekly{/lang}</label>
+ <label><input type="radio" name="dateGrouping" value="monthly" /> {lang}wcf.acp.stat.dateGrouping.monthly{/lang}</label>
+ <label><input type="radio" name="dateGrouping" value="yearly" /> {lang}wcf.acp.stat.dateGrouping.yearly{/lang}</label>
+ </dd>
+ </dl>
+
+ <dl>
+ <dt><label>{lang}wcf.acp.stat.value{/lang}</label></dt>
<dd>
<label><input type="radio" name="value" value="counter" checked="checked" /> {lang}wcf.acp.stat.value.counter{/lang}</label>
<label><input type="radio" name="value" value="total" /> {lang}wcf.acp.stat.value.total{/lang}</label>
</dl>
<dl>
- <dt><label for="startDate">{lang}wcf.acp.stat.types{/lang}</label></dt>
+ <dt><label>{lang}wcf.acp.stat.types{/lang}</label></dt>
<dd>
{foreach from=$availableObjectTypes item=objectType}
<label><input type="checkbox" name="objectTypeID" value="{@$objectType->objectTypeID}" {if $objectType->default}checked="checked" {/if}/> {lang}wcf.acp.stat.{@$objectType->objectType}{/lang}</label>
parent::readData();
// set default values
- $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
+ $d = DateUtil::getDateTimeByTimestamp(TIME_NOW - 86400);
$d->setTimezone(WCF::getUser()->getTimeZone());
$this->endDate = $d->format('Y-m-d');
$d->sub(new \DateInterval('P1M'));
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
if ($objectType === null) throw new UserInputException('objectTypeIDs');
}
+
+ // validate date grouping parameter
+ if (empty($this->parameters['dateGrouping'])) {
+ throw new UserInputException('objectTypeIDs');
+ }
}
/**
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('objectTypeID IN (?)', array($this->parameters['objectTypeIDs']));
$conditionBuilder->add('date BETWEEN ? AND ?', array($this->parameters['startDate'], $this->parameters['endDate']));
- $sql = "SELECT *
- FROM wcf".WCF_N."_stat_daily
- ".$conditionBuilder."
- ORDER BY date";
+
+ 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
+ ".$conditionBuilder."
+ GROUP BY EXTRACT(YEAR FROM date), objectTypeID
+ ORDER BY date";
+ }
+ else if ($this->parameters['dateGrouping'] == 'monthly') {
+ $sql = "SELECT MIN(date) AS date, SUM(counter) AS counter, MAX(total) AS total, objectTypeID
+ FROM wcf".WCF_N."_stat_daily
+ ".$conditionBuilder."
+ GROUP BY EXTRACT(YEAR_MONTH FROM date), objectTypeID
+ ORDER BY date";
+ }
+ else if ($this->parameters['dateGrouping'] == 'weekly') {
+ $sql = "SELECT MIN(date) AS date, SUM(counter) AS counter, MAX(total) AS total, objectTypeID
+ FROM wcf".WCF_N."_stat_daily
+ ".$conditionBuilder."
+ GROUP BY EXTRACT(YEAR FROM date), EXTRACT(WEEK FROM date), objectTypeID
+ ORDER BY date";
+ }
+ else {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_stat_daily
+ ".$conditionBuilder."
+ ORDER BY date";
+ }
+
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
<item name="wcf.acp.rebuildData.com.woltlab.wcf.like.user.description"><![CDATA[Aktualisiert die Liste der Like-Benutzer]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment"><![CDATA[Dateianhänge aktualisieren]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment.description"><![CDATA[Erzeugt Vorschaubilder neu]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily"><![CDATA[Statistiken aktualisieren]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily.description"><![CDATA[Erzeugt die täglichen Statistiken neu]]></item>
</category>
<category name="wcf.acp.search">
<item name="wcf.acp.stat.period"><![CDATA[Zeitraum]]></item>
<item name="wcf.acp.stat.button.refresh"><![CDATA[Aktualisieren]]></item>
<item name="wcf.acp.stat.value"><![CDATA[Werte]]></item>
- <item name="wcf.acp.stat.value.counter"><![CDATA[Einträge pro Tag]]></item>
+ <item name="wcf.acp.stat.value.counter"><![CDATA[Veränderung]]></item>
<item name="wcf.acp.stat.value.total"><![CDATA[Gesamtanzahl]]></item>
<item name="wcf.acp.stat.types"><![CDATA[Daten]]></item>
- <item name="wcf.acp.stat.timeFormat"><![CDATA[%d.%m.%Y]]></item>
+ <item name="wcf.acp.stat.timeFormat.daily"><![CDATA[%d.%m.%y]]></item>
+ <item name="wcf.acp.stat.timeFormat.weekly"><![CDATA[%d.%m.%y]]></item>
+ <item name="wcf.acp.stat.timeFormat.monthly"><![CDATA[%b %Y]]></item>
+ <item name="wcf.acp.stat.timeFormat.yearly"><![CDATA[%Y]]></item>
<item name="wcf.acp.stat.com.woltlab.wcf.user"><![CDATA[Benutzer]]></item>
<item name="wcf.acp.stat.com.woltlab.wcf.attachment"><![CDATA[Dateianhänge]]></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.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>
</category>
<category name="wcf.acp.updateServer">
<item name="wcf.acp.rebuildData.com.woltlab.wcf.like.user.description"><![CDATA[Rebuilds the list of like users]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment"><![CDATA[Rebuild Attachments]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment.description"><![CDATA[Rebuilds attachment preview images]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily"><![CDATA[TODO: Statistiken aktualisieren]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily.description"><![CDATA[TODO: Erzeugt die täglichen Statistiken neu]]></item>
</category>
<category name="wcf.acp.search">
<item name="wcf.acp.stat.period"><![CDATA[TODO: Zeitraum]]></item>
<item name="wcf.acp.stat.button.refresh"><![CDATA[TODO: Aktualisieren]]></item>
<item name="wcf.acp.stat.value"><![CDATA[TODO: Werte]]></item>
- <item name="wcf.acp.stat.value.counter"><![CDATA[TODO: Einträge pro Tag]]></item>
+ <item name="wcf.acp.stat.value.counter"><![CDATA[TODO: Veränderung]]></item>
<item name="wcf.acp.stat.value.total"><![CDATA[TODO: Gesamtanzahl]]></item>
<item name="wcf.acp.stat.types"><![CDATA[TODO: Daten]]></item>
- <item name="wcf.acp.stat.timeFormat"><![CDATA[TODO: %d.%m.%Y]]></item>
+ <item name="wcf.acp.stat.timeFormat.daily"><![CDATA[TODO: %d.%m.%y]]></item>
+ <item name="wcf.acp.stat.timeFormat.weekly"><![CDATA[TODO: %d.%m.%y]]></item>
+ <item name="wcf.acp.stat.timeFormat.monthly"><![CDATA[TODO: %b %Y]]></item>
+ <item name="wcf.acp.stat.timeFormat.yearly"><![CDATA[TODO: %Y]]></item>
<item name="wcf.acp.stat.com.woltlab.wcf.user"><![CDATA[TODO: Benutzer]]></item>
<item name="wcf.acp.stat.com.woltlab.wcf.attachment"><![CDATA[TODO: Dateianhänge]]></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.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.dateGrouping"><![CDATA[TODO: Zeiteinheit]]></item>
+ <item name="wcf.acp.stat.dateGrouping.daily"><![CDATA[TODO: Tag]]></item>
+ <item name="wcf.acp.stat.dateGrouping.weekly"><![CDATA[TODO: Woche]]></item>
+ <item name="wcf.acp.stat.dateGrouping.monthly"><![CDATA[TODO: Monat]]></item>
+ <item name="wcf.acp.stat.dateGrouping.yearly"><![CDATA[TODO: Jahr]]></item>
</category>
<category name="wcf.acp.updateServer">