Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
87.50% |
7 / 8 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| OresScoreFetcher | |
87.50% |
7 / 8 |
|
50.00% |
1 / 2 |
2.01 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getOresScore | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | * |
| 17 | * @file |
| 18 | */ |
| 19 | |
| 20 | namespace AutoModerator; |
| 21 | |
| 22 | use Wikimedia\Rdbms\IConnectionProvider; |
| 23 | use Wikimedia\Rdbms\IReadableDatabase; |
| 24 | |
| 25 | class OresScoreFetcher { |
| 26 | |
| 27 | private IReadableDatabase $dbr; |
| 28 | |
| 29 | /** |
| 30 | * @param IConnectionProvider $dbProvider |
| 31 | */ |
| 32 | public function __construct( IConnectionProvider $dbProvider ) { |
| 33 | $this->dbr = $dbProvider->getReplicaDatabase(); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @param int $revId |
| 38 | * @return mixed|false |
| 39 | */ |
| 40 | public function getOresScore( int $revId ) { |
| 41 | return $this->dbr->newSelectQueryBuilder() |
| 42 | ->select( [ 'oresc_probability', 'oresm_name', 'oresm_version' ] ) |
| 43 | ->from( 'ores_classification' ) |
| 44 | ->join( 'ores_model', null, [ 'oresm_id = oresc_model' ] ) |
| 45 | ->where( [ 'oresc_rev' => $revId, 'oresm_name' => 'revertrisklanguageagnostic' ] ) |
| 46 | ->caller( __METHOD__ ) |
| 47 | ->fetchRow(); |
| 48 | } |
| 49 | } |