This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored.
Release status: unmaintained
|Implementation||Parser function, User activity|
|Description||Adds a parser function to return a bullet list of most viewed pages within the last 24 hours|
|Author(s)||Aran Dunkley (Nadtalk)|
|Latest version||1.0.10 (2008-06-07)|
|License||GNU Lesser General Public License 2.1|
|Download||from external repository
|Translate the CurrentPages extension if it is available at translatewiki.net|
|Check usage and version matrix.|
The CurrentPages 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)
- Download and place the file(s) in a directory called
To add the list to an article, use the following parser function syntax:
There are also two parameters that can be added, the first is the maximum number of items to show in the list which defaults to 10 if not supplied. The second specifies the format to use for each item where $1 is replaced with the article link and $2 with the number of views of that article. The default is to start with an asterisk to start a bullet-list item, and the default ending is a newline character. The following example creates a 50 item list with the number of views in brackets after the title link.
When I first made this extension it used a file to store the hit data in, but I didn't realise how much data would need to be read in on each request. On our site which is not that popular the file would be over a megabyte, so I changed the storage method to use a database table instead, which is much more efficient.
For a normal page request there are only two single-row SELECT queries and one single-row UPDATE necessary to add the new title request to the counter table. Once per hour an additional single-row UPDATE and multi-row DELETE will occur to clear out the titles from the 24hr old data. To render the list, a multi-row SELECT query limited to the number of items in the list is performed.
It could be made more efficient again by doing processing once per hour and calculating the hourly totals from the current hit counter table. The numbers would only change each hour, and the rendered list could be cached.
- For some reason most page requests increase the count by two (perhaps hooking in before redirect?)
- If there are no requests for more than an hour the information will not be cleared for the hours during that period, but in reality no site connected to the internet would have no requests in any given hour.