test rolling average'
This commit is contained in:
parent
474e215151
commit
9137949dbf
|
@ -39,6 +39,7 @@
|
|||
<th>{% trans "IPs last hour" %}</th>
|
||||
<th>{% trans "IPs last day" %}</th>
|
||||
<th>{% trans "IPs last week" %}</th>
|
||||
<th>{% trans "7 day PPH moving average" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -76,6 +77,9 @@
|
|||
<td class="minimal">
|
||||
<span>{{ boardStat.weekly_ips }}</span>
|
||||
</td>
|
||||
<td class="minimal">
|
||||
<span>{{ boardStat.rolling_average }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
$boardStat['hourly_ips'] = Categories::countUniqueIps($hourly, $HOUR, $_board);
|
||||
$boardStat['daily_ips'] = Categories::countUniqueIps($daily, $DAY, $_board);
|
||||
$boardStat['weekly_ips'] = Categories::countUniqueIps($weekly, $WEEK, $_board);
|
||||
$boardStat['rolling_average'] = Categories::rollingAveragePPH($WEEK, $_board);
|
||||
|
||||
$pph_query = query(
|
||||
sprintf("SELECT COUNT(*) AS count FROM ``posts_%s`` WHERE time > %d",
|
||||
|
@ -155,6 +156,19 @@
|
|||
return count($uniqueIps);
|
||||
}
|
||||
|
||||
private static function rollingAveragePPH($timespan, $_board) {
|
||||
$pph_query = query(
|
||||
sprintf("SELECT AVG(count) as rolling FROM (
|
||||
SELECT HOUR(FROM_UNIXTIME(time)) AS hour, DAYOFYEAR(FROM_UNIXTIME(time)) AS day, COUNT(*) AS count
|
||||
FROM ``posts_%s``
|
||||
WHERE time > %d
|
||||
GROUP BY hour, day",
|
||||
$_board['uri'],
|
||||
time()-$timespan)
|
||||
) or error(db_error());
|
||||
|
||||
return $pph_query->fetch()['rolling'];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue