Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php |
— | — | @@ -38,12 +38,19 @@ |
39 | 39 | $query = $this->getQueryInfo(); |
40 | 40 | $query['fields'] = $this->getQueryFields(); |
41 | 41 | |
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 | + } |
43 | 49 | |
44 | 50 | if ( $params['normalized'] ) { |
45 | | - // Do data normalisation stuffs here |
| 51 | + // TODO: Do data normalisation stuffs here |
46 | 52 | } |
47 | 53 | |
| 54 | + // TODO: Data formatting |
48 | 55 | foreach( $params['data'] as $data ) { |
49 | 56 | switch ( $data ) { |
50 | 57 | case 'timeseries': |
— | — | @@ -58,7 +65,7 @@ |
59 | 66 | break; |
60 | 67 | } |
61 | 68 | } |
62 | | - // $params['reportlanguage'] Change join based on select language |
| 69 | + // TODO: Change join based on selected language $params['reportlanguage'] |
63 | 70 | |
64 | 71 | foreach( $this->getAllowedFilters() as $filter ) { |
65 | 72 | if ( /*isset( $params[$filter] ) && */count( $params[$filter] ) ) { |
— | — | @@ -75,10 +82,12 @@ |
76 | 83 | break; |
77 | 84 | case 'selectcountries': |
78 | 85 | // b, c, d |
| 86 | + // TODO: Cater for "top:20" etc |
79 | 87 | $query['conds']['country_code'] = $parsedFilter; |
80 | 88 | break; |
81 | 89 | case 'selectwebproperties': |
82 | 90 | // c, d |
| 91 | + // TODO: Cater for "top:20" etc |
83 | 92 | $query['conds']['web_property'] = $parsedFilter; |
84 | 93 | break; |
85 | 94 | case 'selectprojects': |
— | — | @@ -87,25 +96,28 @@ |
88 | 97 | break; |
89 | 98 | case 'selectwikis': |
90 | 99 | // c |
| 100 | + // TODO: What's the format of the query need to be? |
91 | 101 | // ( lang = ltarget AND project = ptarget ) OR ( lang =ltarget2 AND project = ptarget2 ) |
92 | 102 | $query['conds'][''] = $parsedFilter; |
93 | 103 | break; |
94 | 104 | case 'selecteditors': |
95 | 105 | // b, c |
| 106 | + // TODO: Need where column |
96 | 107 | $query['conds'][''] = $parsedFilter; |
97 | 108 | break; |
98 | 109 | case 'selectedits': |
99 | 110 | // b, c |
| 111 | + // TODO: Need where column |
100 | 112 | $query['conds'][''] = $parsedFilter; |
101 | 113 | break; |
102 | 114 | case 'selectplatform': |
103 | 115 | // b, c |
| 116 | + // TODO: Need where column |
104 | 117 | $query['conds'][''] = $parsedFilter; |
105 | 118 | break; |
106 | 119 | } |
107 | 120 | } |
108 | 121 | } |
109 | | - $db = $this->getDB(); |
110 | 122 | |
111 | 123 | $this->profileDBIn(); |
112 | 124 | $res = $db->select( $query['table'], $query['fields'], $query['conds'], __METHOD__, $query['options'], $query['join_conds'] ); |
— | — | @@ -175,10 +187,13 @@ |
176 | 188 | |
177 | 189 | public function getAllowedParams() { |
178 | 190 | $params = array( |
179 | | - 'months' => array( |
| 191 | + 'startmonth' => array( |
180 | 192 | ApiBase::PARAM_TYPE => 'string', |
181 | 193 | ApiBase::PARAM_REQUIRED => true, |
182 | 194 | ), |
| 195 | + 'endmonth' => array( |
| 196 | + ApiBase::PARAM_TYPE => 'string', |
| 197 | + ), |
183 | 198 | 'normalized' => false, |
184 | 199 | 'data' => array( |
185 | 200 | ApiBase::PARAM_DFLT => 'timeseries', |
— | — | @@ -240,7 +255,8 @@ |
241 | 256 | |
242 | 257 | public function getParamDescription() { |
243 | 258 | 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)', |
245 | 261 | 'normalized' => array( |
246 | 262 | 'Only applies to squidpageviews, where data for each month are recalculated to 30 days (other metrics may follow)', |
247 | 263 | '(WMF Report Card will use normalized time series when available)', |