You are here

public function Logger::requestEventsCount in MongoDB 8.2

Count events matching a request unique_id.

XXX This implementation may be very inefficient in case of a request gone bad generating non-templated varying messages: #requests is O(#templates).

Parameters

string $requestId: The unique_id of the request.

Return value

int The number of events matching the unique_id.

File

modules/mongodb_watchdog/src/Logger.php, line 694

Class

Logger
Class Logger is a PSR/3 Logger using a MongoDB data store.

Namespace

Drupal\mongodb_watchdog

Code

public function requestEventsCount($requestId) : int {
  if (empty($requestId)) {
    return 0;
  }
  $templates = $this
    ->requestTemplates($requestId);
  $count = 0;
  foreach ($templates as $template) {
    $eventCollection = $this
      ->eventCollection($template->_id);
    $selector = [
      'requestTracking_id' => $requestId,
    ];
    $count += $eventCollection
      ->countDocuments($selector);
  }
  return $count;
}