jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/343752 )

Change subject: Expose category totals in API response
......................................................................


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
---
M includes/Hooks.php
1 file changed, 9 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Arlolra: Looks good to me, approved



diff --git a/includes/Hooks.php b/includes/Hooks.php
index 5626e1e..69c6368 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -97,10 +97,15 @@
         */
        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;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/343752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf942b923a0f4047721055ad9cb48aacc5aa6784
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to