Extension talk:CurrentPages

From Organic Design wiki
Revision as of 22:11, 25 May 2008 by Nad (talk | contribs) (talk at MW:Extension:CurrentPages)
Info.svg This talk page pertains specifically to the development of this extension. For more general discussion about bugs and usage etc, please refer to the mediawiki.org talk page at MW:Extension talk:CurrentPages

About

This extension is basically a hit counter recording the number of normal page views to each article. The difference between this extension and the normal popular pages special-page is that this only records the hits for the last 24 hours. It does this by storing the current hour along with each title and its view count. It creates a database table called currentpages_hourlyviews to store the data in, the structure of which is shown below.

It also stores the current hour in the database and when the current hour changes it deletes any existing rows exhibiting the new hour. It does this so that items more than 24 hours old are purged.

mysql> describe currentpages_hourlyviews;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| hour  | int(11) | YES  |     | NULL    |       | 
| page  | int(11) | YES  |     | NULL    |       | 
| views | int(11) | YES  |     | NULL    |       | 
+-------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec)

Bugs

  • For some reason most page requests increase the count by two

Storing the data in a file

The main code was like this before, where it serialised and deserialised the data array into a file. The problem was that the file started getting quite large which is a big problem considering that its loaded and saved for every request. Due to this, the storage mechanism was changed to use the database instead.