\Drupal\strata\Timeline TimelineQuery

Turns the commit index into the buckets a timeline draws.

The aggregation is done in SQL rather than in PHP. A year of history on a busy site is hundreds of thousands of commits, and loading them to add up seven columns would cost more memory than the page has - so the resolution is turned into an integer division inside the query and the database returns one row per bar.

Empty buckets are filled in. A query returns only the buckets that have commits, and a chart drawn from those alone shows a continuous line across a period when nothing happened, which reads as steady activity rather than as silence. So every bucket the window defines is present, and the quiet ones are explicitly empty.

Restores are counted alongside commits because they belong on the same axis: an operator looking at a spike wants to know whether a rollback caused it, and putting the two on separate charts makes that a comparison of x-axes by eye.

Summary

Methods
Properties
Constants
__construct
buckets
fullHistory
commitsIn
totals
capturedRawBytes
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
aggregate
restores
identifiers
database
commits
No private constants found

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

$commits

$commits : \Drupal\strata\Tree\CommitIndex

Type

CommitIndex

Methods

__construct()

__construct(\Drupal\Core\Database\Connection  $database, \Drupal\strata\Tree\CommitIndex  $commits) : mixed

Constructs a query.

Parameters

\Drupal\Core\Database\Connection $database

The database the indexes live in.

\Drupal\strata\Tree\CommitIndex $commits

Reads individual commits for a drilldown.

Returns

mixed —

buckets()

buckets(\Drupal\strata\Timeline\TimelineWindow  $window) : list<\Drupal\strata\Timeline\TimelineBucket>

The buckets a window covers, oldest first.

Parameters

\Drupal\strata\Timeline\TimelineWindow $window

The window.

Returns

list<\Drupal\strata\Timeline\TimelineBucket> —

One bucket per boundary the window defines.

fullHistory()

fullHistory(int  $fallbackNow) : \Drupal\strata\Timeline\TimelineWindow

The span the whole history covers.

What a timeline opens on when the caller has no window in mind.

Parameters

int $fallbackNow

The unix second to use when there is no history.

Returns

\Drupal\strata\Timeline\TimelineWindow —

A window over every commit, or over the last hour when there are none.

commitsIn()

commitsIn(\Drupal\strata\Timeline\TimelineBucket  $bucket, int  $limit = 100) : list<array<string,mixed>>

The commits inside one bucket, newest first.

Parameters

\Drupal\strata\Timeline\TimelineBucket $bucket

The bucket.

int $limit

Most rows to return.

Returns

list> —

Commit index rows.

totals()

totals(\Drupal\strata\Timeline\TimelineWindow  $window) : array{commits: int, operations: int, raw_bytes: int, stored_bytes: int, anchors: int}

Totals across a whole window, without bucketing.

Parameters

\Drupal\strata\Timeline\TimelineWindow $window

The window.

Returns

array{commits: int, operations: int, raw_bytes: int, stored_bytes: int, anchors: int} —

The totals.

capturedRawBytes()

capturedRawBytes() : int

Raw bytes every indexed commit says it captured.

Over the whole history rather than a window, because it is the numerator of a store-wide deduplication ratio and the denominator is a whole-store figure too.

Returns

int —

Bytes.

aggregate()

aggregate(\Drupal\strata\Timeline\TimelineWindow  $window) : array<int,array<string,mixed>>

Commit totals per bucket.

Parameters

\Drupal\strata\Timeline\TimelineWindow $window

The window.

Returns

array> —

Bucket start keyed to its totals.

restores()

restores(\Drupal\strata\Timeline\TimelineWindow  $window) : array<int,int>

How many restores ran in each bucket.

Parameters

\Drupal\strata\Timeline\TimelineWindow $window

The window.

Returns

array

Bucket start keyed to a count.

identifiers()

identifiers(\Drupal\strata\Timeline\TimelineWindow  $window) : array<int,list<string>>

A bounded list of commit ids per bucket.

Read as one ordered pass rather than one query per bucket: a window can hold hundreds of buckets, and a query each would be hundreds of round trips for a chart.

Parameters

\Drupal\strata\Timeline\TimelineWindow $window

The window.

Returns

array> —

Bucket start keyed to commit ids, newest first.