Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
UnscannedImagesMetric
100.00% covered (success)
100.00%
8 / 8
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%
6 / 6
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 number of unscanned images (mms_is_match as NULL) in the
10 * mediamoderation_scan table.
11 */
12class UnscannedImagesMetric 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            ->where( [ 'mms_is_match' => null ] )
25            ->caller( __METHOD__ )
26            ->fetchField();
27    }
28
29    /** @inheritDoc */
30    public function getName(): string {
31        return 'scan_table_unscanned_total';
32    }
33}