r91498 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91497‎ | r91498 | r91499 >
Date:22:01, 5 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Array-ise stuff
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
@@ -35,6 +35,9 @@
3636 public function execute() {
3737 $params = $this->extractRequestParams();
3838
 39+ if ( $this->canBeNormalised() && $params['normalized'] ) {
 40+ $this->normaliseQueryParameters( $params );
 41+ }
3942 $query = $this->getQueryInfo();
4043 $query['fields'] = $this->getQueryFields();
4144
@@ -48,10 +51,6 @@
4952 . " AND date <= " . $db->addQuotes( $params['endmonth'] ) ;
5053 }
5154
52 - if ( $this->canBeNormalised() && $params['normalized'] ) {
53 - $params = $this->normaliseQueryParameters( $params );
54 - }
55 -
5655 // TODO: Data formatting
5756 foreach( $params['data'] as $data ) {
5857 switch ( $data ) {
@@ -211,9 +210,9 @@
212211 }
213212
214213 /**
215 - * @return string
 214+ * @return array
216215 */
217 - public /*abstract*/ function getMetricField() {
 216+ public function getMetricField() {
218217 return '';
219218 }
220219
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricField() {
27 - return 'editors_new';
 27+ return array( 'editors_new' );
2828 }
2929
3030 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
@@ -14,8 +14,7 @@
1515 'table' => array( 'comscore', 'comscore_regions'),
1616 'conds' => array(),
1717 'options' => array( 'ORDER BY' => 'comscore.region_code, date' ),
18 - 'join_conds' => array(
19 - 'comscore_regions' => array( 'LEFT JOIN', "comscore.region_code = comscore_regions.region_code" )
 18+ 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', "comscore.region_code = comscore_regions.region_code" )
2019 ),
2120 );
2221 }
@@ -29,7 +28,7 @@
3029 }
3130
3231 public function getMetricField() {
33 - return 'reach';
 32+ return array( 'reach' );
3433 }
3534
3635 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricField() {
27 - return 'edits';
 27+ return array( 'edits' );
2828 }
2929
3030 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricField() {
27 - return '';
 27+ return array( '' );
2828 }
2929
3030 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php
@@ -24,7 +24,7 @@
2525 }
2626
2727 public function getMetricField() {
28 - return "SUM(editors_ge_{$this->numberOfActiveEditors})";
 28+ return array( "SUM(editors_ge_{$this->numberOfActiveEditors})" );
2929 }
3030
3131 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -2,6 +2,12 @@
33
44 class SquidPageViewsMetric extends ApiAnalyticsBase {
55
 6+ public function __construct( ApiBase $query, $moduleName, $paramPrefix = '' ) {
 7+ parent::__construct( $query->getMain(), $moduleName, $paramPrefix );
 8+
 9+ $this->normaliseQueryParameters();
 10+ }
 11+
612 public function getAllowedFilters() {
713 return array(
814 'selectregions',
@@ -22,23 +28,32 @@
2329 );
2430 }
2531
 32+ protected $queryFields;
 33+
2634 protected function getQueryFields() {
27 - return array();
 35+ return $this->queryFields;
2836 }
2937
 38+ protected $metricField;
 39+
3040 public function getMetricField() {
31 - // views_non_mobile_raw,views_mobile_raw,views_non_mobile_normalized,views_mobile_normalized depending on normalized and select_platform
32 - return '';
 41+ // , views_mobile_raw, views_non_mobile_normalized, views_mobile_normalized depending on normalized and select_platform
 42+ return $this->metricField;
3343 }
3444
3545 protected function canBeNormalised() {
3646 return true;
3747 }
3848
39 - public function normaliseQueryParameters( $params ) {
 49+ public function normaliseQueryParameters( $normalise = false ) {
4050 // TODO: Change fields/table to normalise data set returned
4151 // Swap page_views for page_views_v
42 - return $params;
 52+
 53+ if ( $normalise ) {
 54+ $this->metricField = $this->queryFields = array( 'views_mobile_raw', 'views_non_mobile_raw' );
 55+ } else {
 56+ $this->metricField = $this->queryFields = array( 'views_mobile_normalized', 'views_non_mobile_normalized' );
 57+ }
4358 }
4459
4560 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
@@ -14,7 +14,8 @@
1515 'table' => array( 'comscore', 'comscore_regions' ),
1616 'conds' => array(),
1717 'options' => array( 'ORDER BY' => 'date, project_code, region_code' ),
18 - 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', 'comscore.region_code = comscore_regions.region_code' ) ),
 18+ 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', 'comscore.region_code = comscore_regions.region_code' )
 19+ ),
1920 );
2021 }
2122
@@ -30,7 +31,7 @@
3132 }
3233
3334 public function getMetricField() {
34 - return 'visitors';
 35+ return array( 'visitors' );
3536 }
3637
3738 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricField() {
27 - return 'reach';
 27+ return array( 'reach' );
2828 }
2929
3030 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricField() {
27 - return '';
 27+ return array( '' );
2828 }
2929
3030 public function getDescription() {

Status & tagging log