mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-23 23:44:17 +00:00
Expose category totals in API response
Instead of just including the error category names, include the number of errors each category has, to make it easier to collect aggregate stats. This changes the structure from an array to an object, in JSON, but I'm not aware of any clients using these specific fields yet. Change-Id: Iaf942b923a0f4047721055ad9cb48aacc5aa6784
This commit is contained in:
parent
f54e65b6c7
commit
45b4bf6382
|
@ -97,10 +97,15 @@ class Hooks {
|
|||
*/
|
||||
public static function onAPIQuerySiteInfoGeneralInfo( ApiQuerySiteInfo $api, array &$data ) {
|
||||
$catManager = new CategoryManager();
|
||||
$data['linter'] = [
|
||||
'errors' => $catManager->getErrors(),
|
||||
'warnings' => $catManager->getWarnings(),
|
||||
];
|
||||
$totals = ( new Database( 0 ) )->getTotals();
|
||||
$info = [];
|
||||
foreach ( $catManager->getErrors() as $error ) {
|
||||
$info['errors'][$error] = $totals[$error];
|
||||
}
|
||||
foreach ( $catManager->getWarnings() as $warning ) {
|
||||
$info['warnings'][$warning] = $totals[$warning];
|
||||
}
|
||||
$data['linter'] = $info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue