Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php |
— | — | @@ -147,24 +147,25 @@ |
148 | 148 | |
149 | 149 | $fields = array_map( array( $this, 'getColumnName' ), $query['fields'] ); |
150 | 150 | |
| 151 | + $storageKey = $titleFields[0]; |
151 | 152 | $things = array(); |
152 | 153 | // Build result set |
153 | 154 | 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 |
155 | 163 | $item = array(); |
156 | 164 | foreach( array_diff( $fields, $titleFields ) as $field ) { |
157 | 165 | $item[$field] = $row->$field; |
158 | 166 | } |
159 | 167 | |
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' ); |
169 | 170 | } |
170 | 171 | |
171 | 172 | // Add data to the output |