Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php |
— | — | @@ -35,6 +35,9 @@ |
36 | 36 | public function execute() { |
37 | 37 | $params = $this->extractRequestParams(); |
38 | 38 | |
| 39 | + if ( $this->canBeNormalised() && $params['normalized'] ) { |
| 40 | + $this->normaliseQueryParameters( $params ); |
| 41 | + } |
39 | 42 | $query = $this->getQueryInfo(); |
40 | 43 | $query['fields'] = $this->getQueryFields(); |
41 | 44 | |
— | — | @@ -48,10 +51,6 @@ |
49 | 52 | . " AND date <= " . $db->addQuotes( $params['endmonth'] ) ; |
50 | 53 | } |
51 | 54 | |
52 | | - if ( $this->canBeNormalised() && $params['normalized'] ) { |
53 | | - $params = $this->normaliseQueryParameters( $params ); |
54 | | - } |
55 | | - |
56 | 55 | // TODO: Data formatting |
57 | 56 | foreach( $params['data'] as $data ) { |
58 | 57 | switch ( $data ) { |
— | — | @@ -211,9 +210,9 @@ |
212 | 211 | } |
213 | 212 | |
214 | 213 | /** |
215 | | - * @return string |
| 214 | + * @return array |
216 | 215 | */ |
217 | | - public /*abstract*/ function getMetricField() { |
| 216 | + public function getMetricField() { |
218 | 217 | return ''; |
219 | 218 | } |
220 | 219 | |
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricField() { |
27 | | - return 'editors_new'; |
| 27 | + return array( 'editors_new' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php |
— | — | @@ -14,8 +14,7 @@ |
15 | 15 | 'table' => array( 'comscore', 'comscore_regions'), |
16 | 16 | 'conds' => array(), |
17 | 17 | '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" ) |
20 | 19 | ), |
21 | 20 | ); |
22 | 21 | } |
— | — | @@ -29,7 +28,7 @@ |
30 | 29 | } |
31 | 30 | |
32 | 31 | public function getMetricField() { |
33 | | - return 'reach'; |
| 32 | + return array( 'reach' ); |
34 | 33 | } |
35 | 34 | |
36 | 35 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricField() { |
27 | | - return 'edits'; |
| 27 | + return array( 'edits' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricField() { |
27 | | - return ''; |
| 27 | + return array( '' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function getMetricField() { |
28 | | - return "SUM(editors_ge_{$this->numberOfActiveEditors})"; |
| 28 | + return array( "SUM(editors_ge_{$this->numberOfActiveEditors})" ); |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php |
— | — | @@ -2,6 +2,12 @@ |
3 | 3 | |
4 | 4 | class SquidPageViewsMetric extends ApiAnalyticsBase { |
5 | 5 | |
| 6 | + public function __construct( ApiBase $query, $moduleName, $paramPrefix = '' ) { |
| 7 | + parent::__construct( $query->getMain(), $moduleName, $paramPrefix ); |
| 8 | + |
| 9 | + $this->normaliseQueryParameters(); |
| 10 | + } |
| 11 | + |
6 | 12 | public function getAllowedFilters() { |
7 | 13 | return array( |
8 | 14 | 'selectregions', |
— | — | @@ -22,23 +28,32 @@ |
23 | 29 | ); |
24 | 30 | } |
25 | 31 | |
| 32 | + protected $queryFields; |
| 33 | + |
26 | 34 | protected function getQueryFields() { |
27 | | - return array(); |
| 35 | + return $this->queryFields; |
28 | 36 | } |
29 | 37 | |
| 38 | + protected $metricField; |
| 39 | + |
30 | 40 | 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; |
33 | 43 | } |
34 | 44 | |
35 | 45 | protected function canBeNormalised() { |
36 | 46 | return true; |
37 | 47 | } |
38 | 48 | |
39 | | - public function normaliseQueryParameters( $params ) { |
| 49 | + public function normaliseQueryParameters( $normalise = false ) { |
40 | 50 | // TODO: Change fields/table to normalise data set returned |
41 | 51 | // 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 | + } |
43 | 58 | } |
44 | 59 | |
45 | 60 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php |
— | — | @@ -14,7 +14,8 @@ |
15 | 15 | 'table' => array( 'comscore', 'comscore_regions' ), |
16 | 16 | 'conds' => array(), |
17 | 17 | '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 | + ), |
19 | 20 | ); |
20 | 21 | } |
21 | 22 | |
— | — | @@ -30,7 +31,7 @@ |
31 | 32 | } |
32 | 33 | |
33 | 34 | public function getMetricField() { |
34 | | - return 'visitors'; |
| 35 | + return array( 'visitors' ); |
35 | 36 | } |
36 | 37 | |
37 | 38 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricField() { |
27 | | - return 'reach'; |
| 27 | + return array( 'reach' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricField() { |
27 | | - return ''; |
| 27 | + return array( '' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |