You are here

function recommender_cron in Recommender API 6.3

Same name and namespace in other branches
  1. 6.2 recommender.module \recommender_cron()
  2. 7.6 recommender.module \recommender_cron()
  3. 7.3 recommender.module \recommender_cron()
  4. 7.4 recommender.module \recommender_cron()
  5. 7.5 recommender.module \recommender_cron()

File

./recommender.module, line 177
Providing generic recommender system algorithms.

Code

function recommender_cron() {

  // if cron is null, then never run cron for the app.
  // else if recommender never get executed (execution_id=null), then run it.
  // otherwise, run only when last command (c.created) is before current time minus cron.
  $result = db_query('SELECT a.name FROM {recommender_app} a LEFT OUTER JOIN {async_command} c ON a.execution_id = c.id
  		WHERE cron IS NOT NULL AND (a.execution_id IS NULL OR c.created + a.cron < %d)', time());
  while ($row = db_fetch_array($result)) {
    recommender_create_command($row->name);
  }
}