You are here

protected function RateBotDetector::checkThreshold in Rate 8

Check the number of votes between now and $interval seconds ago.

Parameters

int $interval: Interval in seconds.

Return value

int Number of votes between not and internval.

1 call to RateBotDetector::checkThreshold()
RateBotDetector::checkIsBot in src/RateBotDetector.php
Check if the current user is blocked.

File

src/RateBotDetector.php, line 143

Class

RateBotDetector
The rate.bot_detector service.

Namespace

Drupal\rate

Code

protected function checkThreshold($interval) {
  $sql = 'SELECT COUNT(*) FROM {votingapi_vote} WHERE vote_source = :ip AND timestamp > :time';
  return $this->database
    ->query($sql, [
    ':ip' => $this->ip,
    ':time' => \Drupal::time()
      ->getRequestTime() - $interval,
  ])
    ->fetchField();
}