Extension:CurrentPages

This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored.

If you are interested in taking on the task of developing and maintaining this extension, you can request repository ownership. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{extension}} infobox.

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.

To add the list to an article, use the following parser function syntax:

{{#currentpages:}}

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.