r91236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91235‎ | r91236 | r91237 >
Date:23:53, 30 June 2011
Author:reedy
Status:deferred
Tags:
Comment:
Date range parsing, done as seperate parameters

TODO notes
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -38,12 +38,19 @@
3939 $query = $this->getQueryInfo();
4040 $query['fields'] = $this->getQueryFields();
4141
42 - $query['conds']['date'] = $params['months'];
 42+ $db = $this->getDB();
 43+ if ( $params['startmonth'] && !$params['endmonth'] ) {
 44+ $query['conds']['date'] = $params['months'];
 45+ } else {
 46+ $query['conds'] = "date >= ". $db->addQuotes( $params['startmonth'] )
 47+ . " AND date <= " . $db->addQuotes( $params['endmonth'] ) ;
 48+ }
4349
4450 if ( $params['normalized'] ) {
45 - // Do data normalisation stuffs here
 51+ // TODO: Do data normalisation stuffs here
4652 }
4753
 54+ // TODO: Data formatting
4855 foreach( $params['data'] as $data ) {
4956 switch ( $data ) {
5057 case 'timeseries':
@@ -58,7 +65,7 @@
5966 break;
6067 }
6168 }
62 - // $params['reportlanguage'] Change join based on select language
 69+ // TODO: Change join based on selected language $params['reportlanguage']
6370
6471 foreach( $this->getAllowedFilters() as $filter ) {
6572 if ( /*isset( $params[$filter] ) && */count( $params[$filter] ) ) {
@@ -75,10 +82,12 @@
7683 break;
7784 case 'selectcountries':
7885 // b, c, d
 86+ // TODO: Cater for "top:20" etc
7987 $query['conds']['country_code'] = $parsedFilter;
8088 break;
8189 case 'selectwebproperties':
8290 // c, d
 91+ // TODO: Cater for "top:20" etc
8392 $query['conds']['web_property'] = $parsedFilter;
8493 break;
8594 case 'selectprojects':
@@ -87,25 +96,28 @@
8897 break;
8998 case 'selectwikis':
9099 // c
 100+ // TODO: What's the format of the query need to be?
91101 // ( lang = ltarget AND project = ptarget ) OR ( lang =ltarget2 AND project = ptarget2 )
92102 $query['conds'][''] = $parsedFilter;
93103 break;
94104 case 'selecteditors':
95105 // b, c
 106+ // TODO: Need where column
96107 $query['conds'][''] = $parsedFilter;
97108 break;
98109 case 'selectedits':
99110 // b, c
 111+ // TODO: Need where column
100112 $query['conds'][''] = $parsedFilter;
101113 break;
102114 case 'selectplatform':
103115 // b, c
 116+ // TODO: Need where column
104117 $query['conds'][''] = $parsedFilter;
105118 break;
106119 }
107120 }
108121 }
109 - $db = $this->getDB();
110122
111123 $this->profileDBIn();
112124 $res = $db->select( $query['table'], $query['fields'], $query['conds'], __METHOD__, $query['options'], $query['join_conds'] );
@@ -175,10 +187,13 @@
176188
177189 public function getAllowedParams() {
178190 $params = array(
179 - 'months' => array(
 191+ 'startmonth' => array(
180192 ApiBase::PARAM_TYPE => 'string',
181193 ApiBase::PARAM_REQUIRED => true,
182194 ),
 195+ 'endmonth' => array(
 196+ ApiBase::PARAM_TYPE => 'string',
 197+ ),
183198 'normalized' => false,
184199 'data' => array(
185200 ApiBase::PARAM_DFLT => 'timeseries',
@@ -240,7 +255,8 @@
241256
242257 public function getParamDescription() {
243258 return array(
244 - 'months' => 'First and last month to include in time series',
 259+ 'startmonth' => 'Start month (if a range), else target month',
 260+ 'endmonth' => 'End month (if a range)',
245261 'normalized' => array(
246262 'Only applies to squidpageviews, where data for each month are recalculated to 30 days (other metrics may follow)',
247263 '(WMF Report Card will use normalized time series when available)',

Status & tagging log