[WIP] Topic View Statistics MOD

Started by Randem, December 26, 2013, 05:57:21 AM

Previous topic - Next topic

Randem

This MOD will track where UNIQUE users go on your SMF site on a daily basis. Allows you to quickly see where the traffic on your site is so that you may tune or re-arrange your site. the stats are on the bottom of the Statistics Center page. You can select from drop down which date that you want to view stats for. Control for this MOD is under Miscellaneous.

Administration Center » Modification Settings » Miscellaneous


Delete log tables for Topic Visits on uninstall.
Delete settings for Topic Visits on uninstall.
Days to retain Topic Visit data (Older data will be deleted automatically).
Last date of automatic Topic Visit log pruning (yyyy-mm-dd).

Your HELPFUL comments are welcome.
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

Just a few observations

1) Quite a few unnecessary files bundled in this archive. All the files with ~ filenames can be excluded.

2) If you are going to do database inserts, there is a proper function for it, $smcFunc['db_insert']. Amongst other things it will let you insert multiple rows into a single table at once.

3) If you are going to insert something into the settings table, you *really* should use updateSettings() which will also deal with things like caching for you.

4) You're right that <code> will have to be used; I somewhat naively assumed you were creating additional tables to log things into which would normally trip the normal logging-on-install functions (so automatic clean-up can be done too for any new tables). But you're doing it every topic view, potentially, issuing queries to check whether the table exists and then to create it. A non trivial overhead added to every topic view, over and above the actual overhead of logging anyway.

5) <search position="end"><![CDATA[]]></search> can be written as <search position="end" />

I'm sorry, I got fed up trying to read this any further; if this were submitted to the mod site, I would be recommending to the Customization Team that major changes would be required.

Randem

1) Yes, I know (WIP) ;D

2) Yes, I take the easy way first (proof of concept) if I can get it to work in the simplest fashion, then I change it to the preferred way. that way I know it is supposed to work and the problem is in the manner of coding. It keeps it simple.

3) Did not understand what that was for. There is no documentation on that function.

There were no results matching the query.

Create the page "UpdateSettings()" on this wiki!


  Went thru code for SMF and got a general idea. Have it working with that now, much simplier.  ;)

4) Will switch to creation of tables on install. The reason for checking for the tables is so that the system did not crash because I was attempting to put data into tables that were deleted somehow. However I believe generating error messages in the log for the missing table would generate more overhead.

5) Changed.

Thanks, This was very helpful.

Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Suki

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Randem

OK, thanks. The search function did not find it... When you know where to look it make it much easier  8)
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Suki

Since that page belongs to the site rather than the forum, when searching you need to use the "Entire Site" option. I just did that.

Also, there is a direct link to the function database page on the upper menu.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Randem

Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Randem

Is there a reverse equivilent to updateSettings? IE. removeSettings / deleteSettings? I did not come across one.
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Suki

Yes and the first result in that search page is: http://support.simplemachines.org/function_db/index.php?action=view_function;id=212 Which is the page for the current version of updateSettings().

Is there a particular reason why you need to remove a setting?  yo can just set it as empty and will give you the same result.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Arantor

No, there is one circumstance where that won't be true: removing them on uninstallation because you're actually done with them. It should be setting them to 0 in that situation if you use updateSettings; I don't recall it ever actually pruning the DB for them (which is why weekly maintenance actually does that check for known variables that could be pruned)

Randem

In the Documentation there is no reference to a function db_delete. Is this correct and I should just do a db_query to delete data from my table (non SMF).
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Arantor

That's correct. Given the variety of possible conditions for a delete (or, for that matter, an update) there are no wrapper functions for them and straight queries should be used.

Basically, $smcFunc's DB functions are all about providing the idea of support for PostgreSQL and SQLite. SELECT for the most part works the same between the three, inserts are different because SMF has several instances where it writes a bunch of rows at once in what would be a single query, but PostgreSQL and SQLite don't like this and need a function to emulate that behaviour. And neither supports REPLACE INTO syntax, which is the other thing covered by db_insert.

UPDATE and DELETE are again much the same as SELECT so no wrapper is really required.

Randem

#12
Here is an update to the [WIP] Topic View MOD - v1.01.

1 - Added Daily Download Tracking.
2 - Added Daily Hourly tracking for Views and Downloads.
3 - Ability to only see either Views or Downloads (or both) in Statistics Center.
4 - Ability to delete (or keep) all settings on uninstall.
5 - Ability to select which date (of available dates) that you want to view from the logs directly from the Statistics Center page.
6 - Allows you to select how many days of logs to keep. Will automatically delete old data.

All settings are available under Administration Center » Modification Settings » Miscellaneous
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Advertisement: