statistics_cron

statistics_cron()

Implements hook_cron().

File

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

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()));
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.