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:
Kunal Mehta 2017-03-20 14:08:55 -07:00
parent f54e65b6c7
commit 45b4bf6382

View file

@ -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;
}
/**