r91502 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91501‎ | r91502 | r91503 >
Date:22:33, 5 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Add some more group bys

De-indent...
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/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
@@ -73,57 +73,58 @@
7474 }
7575
7676 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+ }
8284
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;
128129 }
129130 }
130131
@@ -139,18 +140,51 @@
140141 $metricTotals = array();
141142
142143 foreach( $res as $row ) {
 144+ // Dump all data to output
143145 $item = array();
144146 foreach( $fields as $field ) {
145147 $item[$field] = $row->$field;
146148 }
147149 $data[] = $item;
148150
 151+ // Do some maths
149152 foreach( $metricFields as $field ) {
150153 if ( !isset( $metricTotals[$field] ) ) {
151154 $metricTotals[$field] = 0;
152155 }
153156 $metricTotals[$field] += $row->$field;
154157 }
 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+ }
155189 }
156190
157191 $result->setIndexedTagName( $data, 'data' );
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'wikistats' ),
1616 'conds' => array(),
17 - 'options' => array(),
 17+ 'options' => array( 'GROUP BY' => 'date', ),
1818 'join_conds' => array(),
1919 );
2020 }
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'comscore', 'comscore_regions'),
1616 'conds' => array(),
17 - 'options' => array( 'ORDER BY' => 'comscore.region_code, date' ),
 17+ 'options' => array( 'GROUP BY' => 'date', 'ORDER BY' => 'comscore.region_code, date' ),
1818 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', "comscore.region_code = comscore_regions.region_code" )
1919 ),
2020 );
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'wikistats' ),
1616 'conds' => array(),
17 - 'options' => array(),
 17+ 'options' => array( 'GROUP BY' => 'date', ),
1818 'join_conds' => array(),
1919 );
2020 }
Index: trunk/extensions/MetricsReporting/metrics/EstimateOfflineMetric.php
@@ -3,8 +3,7 @@
44 class EstimateOfflineMetric extends ApiAnalyticsBase {
55
66 public function getAllowedFilters() {
7 - return array(
8 - );
 7+ return array();
98 }
109
1110 protected function getQueryInfo() {
@@ -23,11 +22,11 @@
2423 }
2524
2625 public function getMetricFields() {
27 - return array( '' );
 26+ return array( 'readers' );
2827 }
2928
3029 public function getDescription() {
31 - return 'Estimated number of Offline Users';
 30+ return 'Estimated number of people whom access Wikipedia through an offline reader';
3231 }
3332
3433 protected function getExamples() {
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -23,7 +23,7 @@
2424 return array(
2525 'table' => array( 'page_views' ),
2626 'conds' => array(),
27 - 'options' => array(),
 27+ 'options' => array( 'GROUP BY' => 'date', ),
2828 'join_conds' => array(),
2929 );
3030 }
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'comscore', 'comscore_regions' ),
1616 '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' ),
1818 'join_conds' => array( 'comscore_regions' => array( 'LEFT JOIN', 'comscore.region_code = comscore_regions.region_code' )
1919 ),
2020 );
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'comscores' ),
1616 'conds' => array(),
17 - 'options' => array(),
 17+ 'options' => array( 'GROUP BY' => 'date', ),
1818 'join_conds' => array(),
1919 );
2020 }
@@ -23,7 +23,7 @@
2424 }
2525
2626 public function getMetricFields() {
27 - return array( 'reach' );
 27+ return array( 'reach' );
2828 }
2929
3030 public function getDescription() {
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
@@ -13,7 +13,7 @@
1414 return array(
1515 'table' => array( 'binaries' ),
1616 'conds' => array(),
17 - 'options' => array(),
 17+ 'options' => array( 'GROUP BY' => 'date', ),
1818 'join_conds' => array(),
1919 );
2020 }

Status & tagging log