User:Jeblad/Temporal statistics

Temporal statistics are an adaption of the mw-core to allow calculation of temporal statistics for the last hours, days or weeks. It is intended for low traffic sites without Squid servers in its configuration without caching of traffic data, that is $wgHitcounterUpdateFreq less than or equal to 1.

The adaption uses ring buffers to hold temporal statistics, as default either none or of length 2. One slot in the ring buffer accumulates statistics, then will move on to the next one when the unix time epoch goes from one hour to the next, from one day to the next or from one week to the next. The length of the ring buffers, less one, will give the maximum length of the statistics with the given resolution. In the default configuration that means the previous whole hour is collected in a single slot, the previous whole day or the previous whole week.

Only real pages gets statistics, that is no special pages will have statistics. This should have few practical consequences.

Special page
There will be a special page to get statistics for a single page. The call syntax is Special:Pagestatistics/pagename  and it will display the collected statistics for both global statistics and for temporal statistics.

Configuration
Additional configuration in the, with adaptions in

Altering of page table
The following shows how the database table are changed to accommodate the new functionality. If it is necessary to use lnger time series the number of slots for,   and   are increased accordingly.

Note that some code should be added to verify that the number of slots stays in accordance with the definitions of,   and  .

Patch for Article.php
The patch is an adaption of  to use additional columns in the database table for the page, typically named mw_page.

Note the incViewCount -function does not include the code for bulk updates.