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
 getStatsdKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\MediaModeration\PeriodicMetrics;
4
5use Wikimedia\Rdbms\IReadableDatabase;
6
7/**
8 * A metric that holds the number of unscanned images (mms_is_match as NULL) in the
9 * mediamoderation_scan table.
10 */
11class UnscannedImagesMetric 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            ->where( [ 'mms_is_match' => null ] )
28            ->caller( __METHOD__ )
29            ->fetchField();
30    }
31
32    /** @inheritDoc */
33    public function getStatsdKey(): string {
34        return 'MediaModeration.ScanTable.Unscanned';
35    }
36}