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