Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php |
— | — | @@ -73,57 +73,58 @@ |
74 | 74 | } |
75 | 75 | |
76 | 76 | foreach( $this->getAllowedFilters() as $filter ) { |
77 | | - if ( /*isset( $params[$filter] ) && */count( $params[$filter] ) ) { |
78 | | - if ( $params[$filter][0] === '*' ) { |
79 | | - // For */"all", don't do any filtering |
80 | | - continue; |
81 | | - } |
| 77 | + if ( !isset( $params[$filter] ) ) { |
| 78 | + continue; |
| 79 | + } |
| 80 | + if ( $params[$filter][0] === '*' ) { |
| 81 | + // For */"all", don't do any filtering |
| 82 | + continue; |
| 83 | + } |
82 | 84 | |
83 | | - $parsedFilter = $this->getAllUniqueParams( $params[$filter] ); |
84 | | - switch ( $filter ) { |
85 | | - case 'selectregions': |
86 | | - // a, b, c |
87 | | - $query['conds']['region_code'] = $parsedFilter; |
88 | | - break; |
89 | | - case 'selectcountries': |
90 | | - // b, c, d |
91 | | - // TODO: Cater for "top:20" etc |
92 | | - $query['conds']['country_code'] = $parsedFilter; |
93 | | - break; |
94 | | - case 'selectwebproperties': |
95 | | - /*if ( $params['authcode'] != 'some string' ) { |
96 | | - $this->dieUsage( 'Wrong code', 'badcode' ); |
97 | | - }*/ |
98 | | - // c, d |
99 | | - // TODO: Cater for "top:20" etc |
100 | | - $query['conds']['web_property'] = $parsedFilter; |
101 | | - break; |
102 | | - case 'selectprojects': |
103 | | - // c |
104 | | - $query['conds']['project_code'] = $parsedFilter; |
105 | | - break; |
106 | | - case 'selectwikis': |
107 | | - // c |
108 | | - // TODO: What's the format of the query need to be? |
109 | | - // ( lang = ltarget AND project = ptarget ) OR ( lang =ltarget2 AND project = ptarget2 ) |
110 | | - $query['conds'][''] = $parsedFilter; |
111 | | - break; |
112 | | - case 'selecteditors': |
113 | | - // b, c |
114 | | - // TODO: Need where column |
115 | | - $query['conds'][''] = $parsedFilter; |
116 | | - break; |
117 | | - case 'selectedits': |
118 | | - // b, c |
119 | | - // TODO: Need where column |
120 | | - $query['conds'][''] = $parsedFilter; |
121 | | - break; |
122 | | - case 'selectplatform': |
123 | | - // b, c |
124 | | - // TODO: Need where column |
125 | | - $query['conds'][''] = $parsedFilter; |
126 | | - break; |
127 | | - } |
| 85 | + $parsedFilter = $this->getAllUniqueParams( $params[$filter] ); |
| 86 | + switch ( $filter ) { |
| 87 | + case 'selectregions': |
| 88 | + // a, b, c |
| 89 | + $query['conds']['region_code'] = $parsedFilter; |
| 90 | + break; |
| 91 | + case 'selectcountries': |
| 92 | + // b, c, d |
| 93 | + // TODO: Cater for "top:20" etc |
| 94 | + $query['conds']['country_code'] = $parsedFilter; |
| 95 | + break; |
| 96 | + case 'selectwebproperties': |
| 97 | + /*if ( $params['authcode'] != 'some string' ) { |
| 98 | + $this->dieUsage( 'Wrong code', 'badcode' ); |
| 99 | + }*/ |
| 100 | + // c, d |
| 101 | + // TODO: Cater for "top:20" etc |
| 102 | + $query['conds']['web_property'] = $parsedFilter; |
| 103 | + break; |
| 104 | + case 'selectprojects': |
| 105 | + // c |
| 106 | + $query['conds']['project_code'] = $parsedFilter; |
| 107 | + break; |
| 108 | + case 'selectwikis': |
| 109 | + // c |
| 110 | + // TODO: What's the format of the query need to be? |
| 111 | + // ( lang = ltarget AND project = ptarget ) OR ( lang =ltarget2 AND project = ptarget2 ) |
| 112 | + $query['conds'][''] = $parsedFilter; |
| 113 | + break; |
| 114 | + case 'selecteditors': |
| 115 | + // b, c |
| 116 | + // TODO: Need where column |
| 117 | + $query['conds'][''] = $parsedFilter; |
| 118 | + break; |
| 119 | + case 'selectedits': |
| 120 | + // b, c |
| 121 | + // TODO: Need where column |
| 122 | + $query['conds'][''] = $parsedFilter; |
| 123 | + break; |
| 124 | + case 'selectplatform': |
| 125 | + // b, c |
| 126 | + // TODO: Need where column |
| 127 | + $query['conds'][''] = $parsedFilter; |
| 128 | + break; |
128 | 129 | } |
129 | 130 | } |
130 | 131 | |
— | — | @@ -139,18 +140,51 @@ |
140 | 141 | $metricTotals = array(); |
141 | 142 | |
142 | 143 | foreach( $res as $row ) { |
| 144 | + // Dump all data to output |
143 | 145 | $item = array(); |
144 | 146 | foreach( $fields as $field ) { |
145 | 147 | $item[$field] = $row->$field; |
146 | 148 | } |
147 | 149 | $data[] = $item; |
148 | 150 | |
| 151 | + // Do some maths |
149 | 152 | foreach( $metricFields as $field ) { |
150 | 153 | if ( !isset( $metricTotals[$field] ) ) { |
151 | 154 | $metricTotals[$field] = 0; |
152 | 155 | } |
153 | 156 | $metricTotals[$field] += $row->$field; |
154 | 157 | } |
| 158 | + |
| 159 | + // Make grouped output data |
| 160 | + foreach( $this->getAllowedFilters() as $filter ) { |
| 161 | + if ( !isset( $params[$filter] ) ) { |
| 162 | + continue; |
| 163 | + } |
| 164 | + if ( $params[$filter][0] === '*' ) { |
| 165 | + // For */"all", don't do any filtering |
| 166 | + continue; |
| 167 | + } |
| 168 | + |
| 169 | + $parsedFilter = $this->getAllUniqueParams( $params[$filter] ); |
| 170 | + switch ( $filter ) { |
| 171 | + case 'selectregions': |
| 172 | + break; |
| 173 | + case 'selectcountries': |
| 174 | + break; |
| 175 | + case 'selectwebproperties': |
| 176 | + break; |
| 177 | + case 'selectprojects': |
| 178 | + break; |
| 179 | + case 'selectwikis': |
| 180 | + break; |
| 181 | + case 'selecteditors': |
| 182 | + break; |
| 183 | + case 'selectedits': |
| 184 | + break; |
| 185 | + case 'selectplatform': |
| 186 | + break; |
| 187 | + } |
| 188 | + } |
155 | 189 | } |
156 | 190 | |
157 | 191 | $result->setIndexedTagName( $data, 'data' ); |
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'wikistats' ), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array(), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', ), |
18 | 18 | 'join_conds' => array(), |
19 | 19 | ); |
20 | 20 | } |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'comscore', 'comscore_regions'), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array( 'ORDER BY' => 'comscore.region_code, date' ), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', 'ORDER BY' => 'comscore.region_code, date' ), |
18 | 18 | 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', "comscore.region_code = comscore_regions.region_code" ) |
19 | 19 | ), |
20 | 20 | ); |
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'wikistats' ), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array(), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', ), |
18 | 18 | 'join_conds' => array(), |
19 | 19 | ); |
20 | 20 | } |
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php |
— | — | @@ -3,8 +3,7 @@ |
4 | 4 | class EstimateOfflineMetric extends ApiAnalyticsBase { |
5 | 5 | |
6 | 6 | public function getAllowedFilters() { |
7 | | - return array( |
8 | | - ); |
| 7 | + return array(); |
9 | 8 | } |
10 | 9 | |
11 | 10 | protected function getQueryInfo() { |
— | — | @@ -23,11 +22,11 @@ |
24 | 23 | } |
25 | 24 | |
26 | 25 | public function getMetricFields() { |
27 | | - return array( '' ); |
| 26 | + return array( 'readers' ); |
28 | 27 | } |
29 | 28 | |
30 | 29 | public function getDescription() { |
31 | | - return 'Estimated number of Offline Users'; |
| 30 | + return 'Estimated number of people whom access Wikipedia through an offline reader'; |
32 | 31 | } |
33 | 32 | |
34 | 33 | protected function getExamples() { |
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | return array( |
25 | 25 | 'table' => array( 'page_views' ), |
26 | 26 | 'conds' => array(), |
27 | | - 'options' => array(), |
| 27 | + 'options' => array( 'GROUP BY' => 'date', ), |
28 | 28 | 'join_conds' => array(), |
29 | 29 | ); |
30 | 30 | } |
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'comscore', 'comscore_regions' ), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array( 'ORDER BY' => 'date, project_code, region_code' ), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', 'ORDER BY' => 'date, project_code, region_code' ), |
18 | 18 | 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', 'comscore.region_code = comscore_regions.region_code' ) |
19 | 19 | ), |
20 | 20 | ); |
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'comscores' ), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array(), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', ), |
18 | 18 | 'join_conds' => array(), |
19 | 19 | ); |
20 | 20 | } |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getMetricFields() { |
27 | | - return array( 'reach' ); |
| 27 | + return array( 'reach' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function getDescription() { |
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | return array( |
15 | 15 | 'table' => array( 'binaries' ), |
16 | 16 | 'conds' => array(), |
17 | | - 'options' => array(), |
| 17 | + 'options' => array( 'GROUP BY' => 'date', ), |
18 | 18 | 'join_conds' => array(), |
19 | 19 | ); |
20 | 20 | } |