function NodeStatisticsDatabaseStorage::resetDayCount

Same name in other branches
  1. 8.9.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()
  2. 10 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()
  3. 11.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()

Overrides StatisticsStorageInterface::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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.