You are here

function statspro_cron in Statistics Pro 6.2

Same name and namespace in other branches
  1. 6 statspro.module \statspro_cron()

Implementation of hook_cron().

File

./statspro.module, line 207
Main module of Statistcs pro module

Code

function statspro_cron() {
  require_once drupal_get_path('module', 'statspro') . '/statspro.inc';
  $statspro = new StatsPro();
  $last_run = variable_get('statspro_last_run', 0);
  $days = $statspro
    ->get_days_data($last_run);
  if (count($days) > 0) {
    foreach ($days as $date => $values) {
      $statspro
        ->store_day($date, $values);
    }
    watchdog('statspro', 'New statistics available');
  }
  $term_rebuild = variable_get('statspro_term_rebuild', FALSE);
  if ($term_rebuild) {
    db_query('TRUNCATE TABLE {statspro_term}');
    $statspro
      ->generate_term_stats();
    variable_set('statspro_term_rebuild', FALSE);
  }

  // we always store last run
  variable_set('statspro_last_run', mktime());
}