function NodeStatisticsDatabaseStorage::resetDayCount

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

File

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

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.