function statistics_cron

statistics_cron()

Implements hook_cron().

File

core/modules/statistics/statistics.module, line 72
Logs and displays content statistics for a site.

Code

function statistics_cron() {
  $statistics_timestamp = \Drupal::state()->get('statistics.day_timestamp') ? : 0;

  if ((REQUEST_TIME - $statistics_timestamp) >= 86400) {
    // Reset day counts.
    db_update('node_counter')
      ->fields(array('daycount' => 0))
      ->execute();
    \Drupal::state()->set('statistics.day_timestamp', REQUEST_TIME);
  }

  // Calculate the maximum of node views, for node search ranking.
  \Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1.0, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!statistics!statistics.module/function/statistics_cron/8.1.x