You are here

protected function SanityCheck::initBucketsList in MongoDB 8.2

Prepare a table of bucket to hold the statistics.

1 call to SanityCheck::initBucketsList()
SanityCheck::buildCollectionstats in modules/mongodb_watchdog/src/Install/SanityCheck.php
Build a list of the number of entries per collection in the default DB.

File

modules/mongodb_watchdog/src/Install/SanityCheck.php, line 89

Class

SanityCheck
Class SanityCheck provides some reasonableness checks for MongoDB contents.

Namespace

Drupal\mongodb_watchdog\Install

Code

protected function initBucketsList() : void {
  $barCount = 10;
  $barWidth = $this->items / $barCount;
  $buckets = [
    0 => 0,
    1 => 0,
    $this->items - 1 => 0,
    $this->items => 0,
  ];

  // Values 0, 1 and the value of $items are reserved.
  for ($i = 1; $i < $barCount; $i++) {
    $buckets[$i * $barWidth] = 0;
  }
  ksort($buckets);
  $this->buckets = $buckets;
}