You are here

function yr_verdata_cron in Yr Weatherdata 6.2

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

Implementation of hook_cron().

File

./yr_verdata.module, line 83
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() {
  variable_set('yr_verdata_62', 1);

  // 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 + %d) < %d ORDER BY updated ASC LIMIT 0, 10", array(
    $maxage,
    time(),
  ));

  // And then check the xml for each of them and update as necessary.
  while ($record = db_fetch_object($result)) {
    $load = yr_verdata_load_location($record->yid);
    if ($load['status'] == TRUE) {
      $location = $load['data'];
      _yr_verdata_refresh_xml($location);
    }
  }
}