r92171 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92170‎ | r92171 | r92172 >
Date:17:46, 14 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Few little bits of refactoring
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -7,6 +7,8 @@
88 */
99 protected $mDb;
1010
 11+ protected $isCurrentlyNormalised = false;
 12+
1113 public function __construct( ApiBase $query, $moduleName, $paramPrefix = '' ) {
1214 parent::__construct( $query->getMain(), $moduleName, $paramPrefix );
1315 }
@@ -36,7 +38,7 @@
3739 $params = $this->extractRequestParams();
3840
3941 if ( $this->canBeNormalised() && $params['normalized'] ) {
40 - $this->normaliseQueryParameters( $params );
 42+ $this->normaliseQueryParameters( true );
4143 }
4244 $query = $this->getQueryInfo();
4345 $query['fields'] = $this->getQueryFields();
@@ -49,8 +51,8 @@
5052 } else {
5153 //add 1 month to end of date because of the way data is stored
5254 $endMonth = date( "Y-m-d", strtotime( $params['endmonth'] . " +1 month" ) );
53 -
54 - $query['conds'][] = "date >= ". $db->addQuotes( $params['startmonth'] )
 55+
 56+ $query['conds'][] = "date >= " . $db->addQuotes( $params['startmonth'] )
5557 . " AND date <= " . $db->addQuotes( $endMonth ) ;
5658 }
5759
@@ -235,8 +237,8 @@
236238 * @param $params array
237239 * @return array
238240 */
239 - public function normaliseQueryParameters( $params ) {
240 - return $params;
 241+ public function normaliseQueryParameters( $normalise = false ) {
 242+ $this->isCurrentlyNormalised = $normalise;
241243 }
242244
243245 /**
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -42,7 +42,8 @@
4343 // TODO: Change fields/table to normalise data set returned
4444 // Swap page_views for page_views_v
4545
46 - if (!$normalise ) {
 46+ parent::normaliseQueryParameters( $normalise );
 47+ if ( !$normalise ) {
4748 $this->queryFields = array( 'views_mobile_raw', 'views_non_mobile_raw' );
4849 } else {
4950 $this->queryFields = array( 'views_mobile_normalized', 'views_non_mobile_normalized' );

Status & tagging log