Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
UnscannedImagesWithLastCheckedDefinedMetric
100.00% covered (success)
100.00%
11 / 11
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%
9 / 9
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 defining how many unscanned images (mms_is_match as NULL) which also
9 * have been previously attempted to be scanned (mms_last_checked as not NULL)
10 * are present for a wiki.
11 */
12class UnscannedImagesWithLastCheckedDefinedMetric implements IMetric {
13
14    private IReadableDatabase $dbr;
15
16    /**
17     * @param IReadableDatabase $dbr
18     */
19    public function __construct( IReadableDatabase $dbr ) {
20        $this->dbr = $dbr;
21    }
22
23    /** @inheritDoc */
24    public function calculate(): int {
25        return $this->dbr->newSelectQueryBuilder()
26            ->select( 'COUNT(*)' )
27            ->from( 'mediamoderation_scan' )
28            ->where(
29                $this->dbr->expr( 'mms_is_match', '=', null )
30                    ->and( 'mms_last_checked', '!=', null )
31            )
32            ->caller( __METHOD__ )
33            ->fetchField();
34    }
35
36    /** @inheritDoc */
37    public function getStatsdKey(): string {
38        return 'MediaModeration.ScanTable.UnscannedWithLastCheckedDefined';
39    }
40}