You are here

function yr_verdata_cron in Yr Weatherdata 7

Same name and namespace in other branches
  1. 6.2 yr_verdata.module \yr_verdata_cron()

Implementation of hook_cron().

File

./yr_verdata.module, line 100
yr_verdata.module This file contains the code for getting the forecast from yr.no and displaying it on a Drupal site.

Code

function yr_verdata_cron() {

  // First we get all locations that are not updated within the maxage timeframe.
  $maxage = variable_get('yr_verdata_maxage', 21600);
  $result = db_query("SELECT * FROM {yr_verdata} WHERE (updated + :maxage) < :time ORDER BY updated ASC LIMIT 0, 10", array(
    ':maxage' => $maxage,
    ':time' => REQUEST_TIME,
  ));

  // And we add them to the cron queue.
  $queue = DrupalQueue::get('yr_verdata_locations');
  foreach ($result as $location) {
    $queue
      ->createItem($location);
  }
}