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
 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 defining how many unscanned images (mms_is_match as NULL) which also
10 * have been previously attempted to be scanned (mms_last_checked as not NULL)
11 * are present for a wiki.
12 */
13class UnscannedImagesWithLastCheckedDefinedMetric implements IMetric {
14
15    public function __construct(
16        private readonly IReadableDatabase $dbr,
17    ) {
18    }
19
20    /** @inheritDoc */
21    public function calculate(): int {
22        return (int)$this->dbr->newSelectQueryBuilder()
23            ->select( 'COUNT(*)' )
24            ->from( 'mediamoderation_scan' )
25            ->where(
26                $this->dbr->expr( 'mms_is_match', '=', null )
27                    ->and( 'mms_last_checked', '!=', null )
28            )
29            ->caller( __METHOD__ )
30            ->fetchField();
31    }
32
33    /** @inheritDoc */
34    public function getName(): string {
35        return 'scan_table_unscanned_with_last_checked_defined_total';
36    }
37}