r91501 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91500‎ | r91501 | r91502 >
Date:22:16, 5 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Do some minor refactoring

Try and do some cumulated stats...
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -135,16 +135,28 @@
136136 $data = array();
137137
138138 $fields = array_map( array( $this, 'getColumnName' ), $query['fields'] );
 139+ $metricFields = $this->getMetricFields();
 140+ $metricTotals = array();
 141+
139142 foreach( $res as $row ) {
140143 $item = array();
141144 foreach( $fields as $field ) {
142145 $item[$field] = $row->$field;
143146 }
144147 $data[] = $item;
 148+
 149+ foreach( $metricFields as $field ) {
 150+ if ( !isset( $metricTotals[$field] ) ) {
 151+ $metricTotals[$field] = 0;
 152+ }
 153+ $metricTotals[$field] += $row->$field;
 154+ }
145155 }
146156
147157 $result->setIndexedTagName( $data, 'data' );
 158+ $result->setIndexedTagName( $metricTotals, 'totals' );
148159 $result->addValue( 'metric', $this->getModuleName(), $data );
 160+ $result->addValue( 'totals', $this->getModuleName(), $metricTotals );
149161 }
150162
151163 // TODO: Deal with foo AS bar, and return bar for nicer aliasing of stuff
@@ -212,10 +224,13 @@
213225 /**
214226 * @return array
215227 */
216 - public function getMetricField() {
217 - return '';
 228+ public function getMetricFields() {
 229+ return array();
218230 }
219231
 232+ /**
 233+ * @return bool
 234+ */
220235 protected function takesReportLanguage(){
221236 return false;
222237 }
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
@@ -22,7 +22,7 @@
2323 return array( 'editors_new' );
2424 }
2525
26 - public function getMetricField() {
 26+ public function getMetricFields() {
2727 return array( 'editors_new' );
2828 }
2929
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
@@ -27,7 +27,7 @@
2828 return true;
2929 }
3030
31 - public function getMetricField() {
 31+ public function getMetricFields() {
3232 return array( 'reach' );
3333 }
3434
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
@@ -22,7 +22,7 @@
2323 return array( 'edits' );
2424 }
2525
26 - public function getMetricField() {
 26+ public function getMetricFields() {
2727 return array( 'edits' );
2828 }
2929
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php
@@ -22,7 +22,7 @@
2323 );
2424 }
2525
26 - public function getMetricField() {
 26+ public function getMetricFields() {
2727 return array( '' );
2828 }
2929
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php
@@ -23,7 +23,7 @@
2424 return array( 'date', 'project_code', "SUM(editors_ge_{$this->numberOfActiveEditors})" );
2525 }
2626
27 - public function getMetricField() {
 27+ public function getMetricFields() {
2828 return array( "SUM(editors_ge_{$this->numberOfActiveEditors})" );
2929 }
3030
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -36,7 +36,7 @@
3737
3838 protected $metricField;
3939
40 - public function getMetricField() {
 40+ public function getMetricFields() {
4141 // , views_mobile_raw, views_non_mobile_normalized, views_mobile_normalized depending on normalized and select_platform
4242 return $this->metricField;
4343 }
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
@@ -30,7 +30,7 @@
3131 return true;
3232 }
3333
34 - public function getMetricField() {
 34+ public function getMetricFields() {
3535 return array( 'visitors' );
3636 }
3737
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
@@ -22,7 +22,7 @@
2323 return array( 'reach' );
2424 }
2525
26 - public function getMetricField() {
 26+ public function getMetricFields() {
2727 return array( 'reach' );
2828 }
2929
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
@@ -22,7 +22,7 @@
2323 return array();
2424 }
2525
26 - public function getMetricField() {
 26+ public function getMetricFields() {
2727 return array( '' );
2828 }
2929

Status & tagging log