function votingapi_cron in Voting API 5
Same name and namespace in other branches
- 8.3 votingapi.module \votingapi_cron()
- 6.2 votingapi.module \votingapi_cron()
- 6 votingapi.module \votingapi_cron()
- 7.3 votingapi.module \votingapi_cron()
- 7.2 votingapi.module \votingapi_cron()
Implementation of hook_cron. Allows db-intensive recalculations to put off until cron-time.
File
- ./
votingapi.module, line 495
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);
}
}