Add-on Count Views

Robert9

Well-known member
Yesterday i have watched three addons to count views of resource pages.

1. Themehouse; as usual a lot of code for a lot of things and some code for the addon.
It uses one new table with one field resource_id where every hit of the page just save the resource_id.
With a xf cron job it counts the hits for every resource_id and writes them to a new field xf_resource.view_count

While it isnt running for me, i have written it from new (it is a really short addon). Instead of a cronjob i calculate and update the xf_resource.view_count with a rand(0,300); after more or less 300 views there is an update and we empty the table.

2. Two more addons just count every single call of a resource_view with an update to a new field xf_resource.view_count
One just updates, one use a delayed update.


What do you think is the better way to count that kind of views?

For myself i want to extend that addon to count a page per ip or per user_id;
Here i could do: Save resource_id and ip and maybe the user_id (if this has an index for unique) i cant be saved twice times; but do mysql love this? Or better use a cookie and save only after one hour? Or maybe this just doesnt matter?
 
Back
Top Bottom