mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-28 01:30:05 +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 ) {
|
public static function onAPIQuerySiteInfoGeneralInfo( ApiQuerySiteInfo $api, array &$data ) {
|
||||||
$catManager = new CategoryManager();
|
$catManager = new CategoryManager();
|
||||||
$data['linter'] = [
|
$totals = ( new Database( 0 ) )->getTotals();
|
||||||
'errors' => $catManager->getErrors(),
|
$info = [];
|
||||||
'warnings' => $catManager->getWarnings(),
|
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