You are here

function votingapi_cron in Voting API 6

Same name and namespace in other branches
  1. 8.3 votingapi.module \votingapi_cron()
  2. 5 votingapi.module \votingapi_cron()
  3. 6.2 votingapi.module \votingapi_cron()
  4. 7.3 votingapi.module \votingapi_cron()
  5. 7.2 votingapi.module \votingapi_cron()

Implementation of hook_cron. Allows db-intensive recalculations to put off until cron-time.

File

./votingapi.module, line 50

Code

function votingapi_cron() {
  if (variable_get('votingapi_calculation_schedule', 'immediate') == 'cron') {
    $time = time();
    $last_cron = variable_get('votingapi_last_cron', 0);
    $result = db_query('SELECT DISTINCT content_type, content_id FROM {votingapi_vote} WHERE timestamp > %d', $last_cron);
    while ($content = db_fetch_object($result)) {
      votingapi_recalculate_results($content->content_type, $content->content_id, TRUE);
    }
    variable_set('votingapi_last_cron', $time);
  }
}