Legoktm has uploaded a new change for review. ( 
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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/52/343752/1

diff --git a/includes/Hooks.php b/includes/Hooks.php
index 6498eeb..e2e08a6 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -98,10 +98,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: newchange
Gerrit-Change-Id: Iaf942b923a0f4047721055ad9cb48aacc5aa6784
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

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

Reply via email to