r91574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91573‎ | r91574 | r91575 >
Date:18:09, 6 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Remove getMetricFields, add $titleFields to the output building stuff

Still need to work out "grouping" field, hardcoded to region atm
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -52,7 +52,7 @@
5353 }
5454
5555 // TODO: Data formatting
56 - foreach( $params['data'] as $data ) {
 56+ /*foreach( $params['data'] as $data ) {
5757 switch ( $data ) {
5858 case 'timeseries':
5959 break;
@@ -65,13 +65,15 @@
6666 case 'percentagegrowthfullperiod':
6767 break;
6868 }
69 - }
 69+ }*/
7070 //note: this means if you specify a report language that is not
7171 //fully supported, you won't get a full data set back
7272 if( $this->takesReportLanguage() ){
7373 $query['conds']['report_language'] = $params['reportlanguage'];
7474 }
7575
 76+ $titleFields = array();
 77+
7678 foreach( $this->getAllowedFilters() as $filter ) {
7779 if ( !isset( $params[$filter] ) ) {
7880 continue;
@@ -86,11 +88,14 @@
8789 case 'selectregions':
8890 // a, b, c
8991 $query['conds']['comscore_regions.region_code'] = $parsedFilter;
 92+ $titleFields[] = 'region_code';
 93+ $titleFields[] = 'region_name';
9094 break;
9195 case 'selectcountries':
9296 // b, c, d
9397 // TODO: Cater for "top:20" etc
9498 $query['conds']['country_code'] = $parsedFilter;
 99+ $titleFields[] = '';
95100 break;
96101 case 'selectwebproperties':
97102 /*if ( $params['authcode'] != 'some string' ) {
@@ -99,31 +104,37 @@
100105 // c, d
101106 // TODO: Cater for "top:20" etc
102107 $query['conds']['web_property'] = $parsedFilter;
 108+ $titleFields[] = '';
103109 break;
104110 case 'selectprojects':
105111 // c
106112 $query['conds']['project_code'] = $parsedFilter;
 113+ $titleFields[] = '';
107114 break;
108115 case 'selectwikis':
109116 // c
110117 // TODO: What's the format of the query need to be?
111118 // ( lang = ltarget AND project = ptarget ) OR ( lang =ltarget2 AND project = ptarget2 )
112119 $query['conds'][''] = $parsedFilter;
 120+ $titleFields[] = '';
113121 break;
114122 case 'selecteditors':
115123 // b, c
116124 // TODO: Need where column
117125 $query['conds'][''] = $parsedFilter;
 126+ $titleFields[] = '';
118127 break;
119128 case 'selectedits':
120129 // b, c
121130 // TODO: Need where column
122131 $query['conds'][''] = $parsedFilter;
 132+ $titleFields[] = '';
123133 break;
124134 case 'selectplatform':
125135 // b, c
126136 // TODO: Need where column
127137 $query['conds'][''] = $parsedFilter;
 138+ $titleFields[] = '';
128139 break;
129140 }
130141 }
@@ -141,12 +152,15 @@
142153 foreach( $res as $row ) {
143154 // Dump all data to output
144155 $item = array();
145 - foreach( array_diff( $fields, array( 'region_code', 'region_name' ) ) as $field ) {
 156+ foreach( array_diff( $fields, $titleFields ) as $field ) {
146157 $item[$field] = $row->$field;
147158 }
148159
149 - if( !isset( $things[$row->region_code] ) ) {
150 - $things[$row->region_code] = array( 'region_code' => $row->region_code, 'region_name' => $row->region_name );
 160+ if( !isset( $things[$row->region_code] ) ) { // find dynamic value for each query type
 161+ $things[$row->region_code] = array();
 162+ foreach( $titleFields as $field ) {
 163+ $things[$row->region_code][$field] = $row->$field;
 164+ }
151165 }
152166
153167 $things[$row->region_code]['data'][] = $item;
@@ -157,9 +171,8 @@
158172 foreach( $things as $thing ) {
159173 $result->addValue( array( $this->getModuleName() ), null, $thing );
160174 }
161 - $result->setIndexedTagName_internal( array( $this->getModuleName() ), 'region' );
 175+ $result->setIndexedTagName_internal( array( $this->getModuleName() ), 'set' );
162176
163 -
164177 }
165178
166179 // TODO: Deal with foo AS bar, and return bar for nicer aliasing of stuff
@@ -225,13 +238,6 @@
226239 }
227240
228241 /**
229 - * @return array
230 - */
231 - public function getMetricFields() {
232 - return array();
233 - }
234 -
235 - /**
236242 * @return bool
237243 */
238244 protected function takesReportLanguage(){
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
@@ -22,10 +22,6 @@
2323 return array( 'editors_new' );
2424 }
2525
26 - public function getMetricFields() {
27 - return array( 'editors_new' );
28 - }
29 -
3026 public function getDescription() {
3127 return 'All registered editors that in a certain month for the first time crossed the threshold of 10 edits since signing up';
3228 }
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
@@ -27,10 +27,6 @@
2828 return true;
2929 }
3030
31 - public function getMetricFields() {
32 - return array( 'reach' );
33 - }
34 -
3531 public function getDescription() {
3632 return 'Percentage of total unique visitors to any web property which also visited a Wikimedia Wiki';
3733 }
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
@@ -22,10 +22,6 @@
2323 return array( 'edits' );
2424 }
2525
26 - public function getMetricFields() {
27 - return array( 'edits' );
28 - }
29 -
3026 public function getDescription() {
3127 return 'All edits on articles (as defined by dumparticlecount)';
3228 }
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php
@@ -21,10 +21,6 @@
2222 );
2323 }
2424
25 - public function getMetricFields() {
26 - return array( 'readers' );
27 - }
28 -
2925 public function getDescription() {
3026 return 'Estimated number of people whom access Wikipedia through an offline reader';
3127 }
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php
@@ -23,10 +23,6 @@
2424 return array( 'date', 'project_code', "SUM(editors_ge_{$this->numberOfActiveEditors})" );
2525 }
2626
27 - public function getMetricFields() {
28 - return array( "SUM(editors_ge_{$this->numberOfActiveEditors})" );
29 - }
30 -
3127 public function getDescription() {
3228 return "All registered editors that made {$this->numberOfActiveEditors} or more edits in a certain month";
3329 }
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -34,13 +34,6 @@
3535 return $this->queryFields;
3636 }
3737
38 - protected $metricField;
39 -
40 - public function getMetricFields() {
41 - // , views_mobile_raw, views_non_mobile_normalized, views_mobile_normalized depending on normalized and select_platform
42 - return $this->metricField;
43 - }
44 -
4538 protected function canBeNormalised() {
4639 return true;
4740 }
@@ -50,9 +43,9 @@
5144 // Swap page_views for page_views_v
5245
5346 if ( $normalise ) {
54 - $this->metricField = $this->queryFields = array( 'views_mobile_raw', 'views_non_mobile_raw' );
 47+ $this->queryFields = array( 'views_mobile_raw', 'views_non_mobile_raw' );
5548 } else {
56 - $this->metricField = $this->queryFields = array( 'views_mobile_normalized', 'views_non_mobile_normalized' );
 49+ $this->queryFields = array( 'views_mobile_normalized', 'views_non_mobile_normalized' );
5750 }
5851 }
5952
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
@@ -30,10 +30,6 @@
3131 return true;
3232 }
3333
34 - public function getMetricFields() {
35 - return array( 'visitors' );
36 - }
37 -
3834 public function getDescription() {
3935 return 'Unique persons that visited one of the Wikimedia wikis at least once in a certain month';
4036 }
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
@@ -22,10 +22,6 @@
2323 return array( 'reach' );
2424 }
2525
26 - public function getMetricFields() {
27 - return array( 'reach' );
28 - }
29 -
3026 public function getDescription() {
3127 return 'All namespace 0 pages which contain an internal link minus redirect pages (for some projects extra namespaces qualify)';
3228 }
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
@@ -22,10 +22,6 @@
2323 return array();
2424 }
2525
26 - public function getMetricFields() {
27 - return array( '' );
28 - }
29 -
3026 public function getDescription() {
3127 return 'All binary files (nearly all of which are multimedia files) available for download/article inclusion on a wiki';
3228 }

Status & tagging log