r91576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91575‎ | r91576 | r91577 >
Date:18:20, 6 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Minor refaactoring

Set storage key
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -147,24 +147,25 @@
148148
149149 $fields = array_map( array( $this, 'getColumnName' ), $query['fields'] );
150150
 151+ $storageKey = $titleFields[0];
151152 $things = array();
152153 // Build result set
153154 foreach( $res as $row ) {
154 - // Dump all data to output
 155+ if( !isset( $things[$row->$storageKey] ) ) { // find dynamic value for each query type
 156+ $things[$row->$storageKey] = array();
 157+ foreach( $titleFields as $field ) {
 158+ $things[$row->$storageKey][$field] = $row->$field;
 159+ }
 160+ }
 161+
 162+ // Dump rest of data to output
155163 $item = array();
156164 foreach( array_diff( $fields, $titleFields ) as $field ) {
157165 $item[$field] = $row->$field;
158166 }
159167
160 - if( !isset( $things[$row->region_code] ) ) { // find dynamic value for each query type
161 - $things[$row->region_code] = array();
162 - foreach( $titleFields as $field ) {
163 - $things[$row->region_code][$field] = $row->$field;
164 - }
165 - }
166 -
167 - $things[$row->region_code]['data'][] = $item;
168 - $result->setIndexedTagName( $things[$row->region_code]['data'], 'd' );
 168+ $things[$row->$storageKey]['data'][] = $item;
 169+ $result->setIndexedTagName( $things[$row->$storageKey]['data'], 'd' );
169170 }
170171
171172 // Add data to the output

Status & tagging log