You are here

public function NodeStatisticsDatabaseStorage::resetDayCount in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()
  2. 9 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()

File

core/modules/statistics/src/NodeStatisticsDatabaseStorage.php, line 120

Class

NodeStatisticsDatabaseStorage
Provides the default database storage backend for statistics.

Namespace

Drupal\statistics

Code

public function resetDayCount() {
  $statistics_timestamp = $this->state
    ->get('statistics.day_timestamp', 0);
  if ($this
    ->getRequestTime() - $statistics_timestamp >= 86400) {
    $this->state
      ->set('statistics.day_timestamp', $this
      ->getRequestTime());
    $this->connection
      ->update('node_counter')
      ->fields([
      'daycount' => 0,
    ])
      ->execute();
  }
}