You are here

function recommender_cron in Recommender API 7.4

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

File

./recommender.module, line 221
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.
  $rows = db_query("SELECT a.name FROM {recommender_app} a LEFT OUTER JOIN {async_command} c ON a.execution_id = c.id \n  \t\tWHERE cron IS NOT NULL AND (a.execution_id IS NULL OR c.created + a.cron < :current)", array(
    ':current' => time(),
  ));
  foreach ($rows as $row) {
    recommender_create_command($row->name);
  }
}