Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
TotalTableCountMetric
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 calculate
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare( strict_types=1 );
3
4namespace MediaWiki\Extension\MediaModeration\PeriodicMetrics;
5
6use Wikimedia\Rdbms\IReadableDatabase;
7
8/**
9 * A metric that holds the total table count of the mediamoderation_scan table
10 * for a given wiki.
11 */
12class TotalTableCountMetric implements IMetric {
13
14    public function __construct(
15        private readonly IReadableDatabase $dbr,
16    ) {
17    }
18
19    /** @inheritDoc */
20    public function calculate(): int {
21        return (int)$this->dbr->newSelectQueryBuilder()
22            ->select( 'COUNT(*)' )
23            ->from( 'mediamoderation_scan' )
24            ->caller( __METHOD__ )
25            ->fetchField();
26    }
27
28    /** @inheritDoc */
29    public function getName(): string {
30        return 'scan_table_total';
31    }
32}