Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php |
— | — | @@ -135,16 +135,28 @@ |
136 | 136 | $data = array(); |
137 | 137 | |
138 | 138 | $fields = array_map( array( $this, 'getColumnName' ), $query['fields'] ); |
| 139 | + $metricFields = $this->getMetricFields(); |
| 140 | + $metricTotals = array(); |
| 141 | + |
139 | 142 | foreach( $res as $row ) { |
140 | 143 | $item = array(); |
141 | 144 | foreach( $fields as $field ) { |
142 | 145 | $item[$field] = $row->$field; |
143 | 146 | } |
144 | 147 | $data[] = $item; |
| 148 | + |
| 149 | + foreach( $metricFields as $field ) { |
| 150 | + if ( !isset( $metricTotals[$field] ) ) { |
| 151 | + $metricTotals[$field] = 0; |
| 152 | + } |
| 153 | + $metricTotals[$field] += $row->$field; |
| 154 | + } |
145 | 155 | } |
146 | 156 | |
147 | 157 | $result->setIndexedTagName( $data, 'data' ); |
| 158 | + $result->setIndexedTagName( $metricTotals, 'totals' ); |
148 | 159 | $result->addValue( 'metric', $this->getModuleName(), $data ); |
| 160 | + $result->addValue( 'totals', $this->getModuleName(), $metricTotals ); |
149 | 161 | } |
150 | 162 | |
151 | 163 | // TODO: Deal with foo AS bar, and return bar for nicer aliasing of stuff |
— | — | @@ -212,10 +224,13 @@ |
213 | 225 | /** |
214 | 226 | * @return array |
215 | 227 | */ |
216 | | - public function getMetricField() { |
217 | | - return ''; |
| 228 | + public function getMetricFields() { |
| 229 | + return array(); |
218 | 230 | } |
219 | 231 | |
| 232 | + /** |
| 233 | + * @return bool |
| 234 | + */ |
220 | 235 | protected function takesReportLanguage(){ |
221 | 236 | return false; |
222 | 237 | } |
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | return array( 'editors_new' ); |
24 | 24 | } |
25 | 25 | |
26 | | - public function getMetricField() { |
| 26 | + public function getMetricFields() { |
27 | 27 | return array( 'editors_new' ); |
28 | 28 | } |
29 | 29 | |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | return true; |
29 | 29 | } |
30 | 30 | |
31 | | - public function getMetricField() { |
| 31 | + public function getMetricFields() { |
32 | 32 | return array( 'reach' ); |
33 | 33 | } |
34 | 34 | |
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | return array( 'edits' ); |
24 | 24 | } |
25 | 25 | |
26 | | - public function getMetricField() { |
| 26 | + public function getMetricFields() { |
27 | 27 | return array( 'edits' ); |
28 | 28 | } |
29 | 29 | |
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | ); |
24 | 24 | } |
25 | 25 | |
26 | | - public function getMetricField() { |
| 26 | + public function getMetricFields() { |
27 | 27 | return array( '' ); |
28 | 28 | } |
29 | 29 | |
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | return array( 'date', 'project_code', "SUM(editors_ge_{$this->numberOfActiveEditors})" ); |
25 | 25 | } |
26 | 26 | |
27 | | - public function getMetricField() { |
| 27 | + public function getMetricFields() { |
28 | 28 | return array( "SUM(editors_ge_{$this->numberOfActiveEditors})" ); |
29 | 29 | } |
30 | 30 | |
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | |
38 | 38 | protected $metricField; |
39 | 39 | |
40 | | - public function getMetricField() { |
| 40 | + public function getMetricFields() { |
41 | 41 | // , views_mobile_raw, views_non_mobile_normalized, views_mobile_normalized depending on normalized and select_platform |
42 | 42 | return $this->metricField; |
43 | 43 | } |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | return true; |
32 | 32 | } |
33 | 33 | |
34 | | - public function getMetricField() { |
| 34 | + public function getMetricFields() { |
35 | 35 | return array( 'visitors' ); |
36 | 36 | } |
37 | 37 | |
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | return array( 'reach' ); |
24 | 24 | } |
25 | 25 | |
26 | | - public function getMetricField() { |
| 26 | + public function getMetricFields() { |
27 | 27 | return array( 'reach' ); |
28 | 28 | } |
29 | 29 | |
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | return array(); |
24 | 24 | } |
25 | 25 | |
26 | | - public function getMetricField() { |
| 26 | + public function getMetricFields() { |
27 | 27 | return array( '' ); |
28 | 28 | } |
29 | 29 | |