Project:Stats API
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed

Issue Summary

Hi

I'm the maintainer of the CAPTCHA module and I would be interested to add some statistics stuff to it (like spam attempts per day, popular attack pages, etc). The Stats API seems an interesting route to implement this.

This issue is largely just a form of "subscribing" to the Stats API module progress,
As long as there is no code for Stats API, I can't do more I guess. ;)

Comments

#1

Hi, great to see you're interested! I'm planning to get some code up by at least Thursday but probably sooner. Everything's a little messy right now--I'm not too happy with the API or the method of DB storage--but at least it's working, so I just have to finish filling in some stat calculations for the core modules.

#2

I've just committed the module to CVS. It's pretty messy right now: the stats page needs some styling, and the API and data storage method are less than ideal. Take a look at statsapi_compute_statsapi in the module file to get an idea of what the API looks like.

However, I've done a little research (which I should have done before starting this module) and it looks like there are a couple other projects doing something very similar:

http://drupal.org/project/analytics
http://drupal.org/project/graphstat
http://drupal.org/project/reports
http://drupal.org/project/statspro

I've contacted mikey_p about collaborating on Analytics (it's a GSOC project so it will probably get more attention and love than I can give to this project). I'll update here when I get a response.

#3

Version:<none>» 6.x-1.x-dev
Category:task» support request

FYI, the dev tarball has been generated now.

I talked with mikey_p on IRC and it sounds like his vision for the Analytics module is much more comprehensive than my vision for this module. However, he doesn't have working code at the moment, and with the GSOC deadline so close, I don't know whether his module will materialize.

Having said that, I don't have much time to support or develop this module either.

What I recommend for now is that, if you're interested in using this module for stats, you write integration with the API and I'll put it in this module. That way, if this module survives, you'll be covered; and if it doesn't, you won't have to change anything in CAPTCHA.

Right now, the integration would look something like this:

<?php
/**
* Implementation of hook_compute_statsapi().
*/
function captcha_compute_statsapi() {
 
$result = db_query("SELECT COUNT(csid) count, form_id FROM {captcha_sessions} GROUP BY form_id ORDER BY count DESC");
 
$popular_attacks = array();
  while (
$form = db_fetch_object($result)) {
   
$popular_attacks[] = t('@type: @value', array('@type' => $form->form_id, '@value' => $form->count);
  }
 
$popular = theme('item_list', $popular_attacks);
  return array(
   
'captcha' => array(
     
'Spam attempts per day' => db_result(db_query("SELECT COUNT(*) FROM {captcha_sessions} WHERE timestamp > (%d - 86400) AND status = 0", time())),
     
'Popular attack forms' => $popular,
    ),
  );
}
?>

...not particularly clean, I know, so feel free to make suggestions.

#4

Status:active» postponed

No problem.
Well, the stats stuff was some long term todo item, it's not really urgent for me.
Moreover, for the moment I can't invest much time in it.
So, I think I'll wait till the situation with the stats modules becomes more clear (which ones survive and which ones are a dead end).