Boost module has ajax stats & page tracking working. Recommend grabbing code from boost.

Comments

wiifm’s picture

Title: Use boost code » Boost as an alternative to statistics_ajax
Assigned: Unassigned » wiifm
Status: Active » Closed (works as designed)

Hi @mikeytown2,

I fully agree, if you are already using boost on your site, by all means, enable the extra statistics functionality. I personally was after a more lightweight approach (as I do not use boost), hence this module.

Underneath the covers of both modules (I had a look at boost code), the same db query is being executed:

  // A node has been viewed, so update the node's counters.
  db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), $nid);
  // If we affected 0 rows, this is the first time viewing the node.
  if (!db_affected_rows()) {
    // We must create a new row to store counters for the new node.
    db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', $nid, time());

I will enhance the front page documentation on this module to reflect the fact that users can choose to use the extra functionality available in boost as an alternative to this module

Thanks for pointing this out,
Sean

mikeytown2’s picture

Version: » 6.x-1.0

What I'm saying is steal my code; you will get to where you want to go a lot faster with the benefit of it scaling to millions of hits per day. I do not require a full drupal bootstrap; your current way does & you don't have a way of tracking non nodes.

wiifm’s picture

Thanks @mikeytown2, I have started on a version 2.0 branch, and will look at absorbing some of your code. Thanks for the suggestion

TheoRichel’s picture

Can I use your module *together* with Boost? I do use Boost but the Ajax block that is supposed to supply the statistics only shows node titles and no statistics (yes, the "Display Statistics box is checked). I am working on this for months now so I thought your module could possibly boost Boost here. Of course I am not asking you to support Boost, but since they are so similar I just want to make sure that the two modules do not break anything, that I can try thgem out together.

wiifm’s picture

@TheoRichel - yes they can easily work together, @mikeytown2 was just pointing out that my AJAX call-back currently requires a full drupal bootstrap which can lead to performance issues if your site is dependent on boost to survive.

Give it a go and let me know