r91112 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91111‎ | r91112 | r91113 >
Date:21:50, 29 June 2011
Author:reedy
Status:deferred
Tags:
Comment:
Little bits of code refactoring and additions

Added the first basic metric no functional output yet
Modified paths:
  • /trunk/extensions/MetricsReporting/ApiAnalytics.php (modified) (history)
  • /trunk/extensions/MetricsReporting/ApiAnalyticsBase.php (modified) (history)
  • /trunk/extensions/MetricsReporting/MetricsReporting.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php (added) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/ApiAnalyticsBase.php
@@ -27,6 +27,9 @@
2828 return $this->mDb;
2929 }
3030
 31+ public function execute() {
 32+ }
 33+
3134 /**
3235 * @return array
3336 */
Index: trunk/extensions/MetricsReporting/MetricsReporting.php
@@ -12,6 +12,8 @@
1313 'description' => 'Api for Wikimedia Metrics Reporting output',
1414 );
1515
 16+$wgMetricAPIModules = array();
 17+
1618 $wgMetricsDBserver = '';
1719 //$wgMetricsDBport = 5432;
1820 $wgMetricsDBname = '';
@@ -25,3 +27,8 @@
2628 $wgAPIModules['analytics'] = 'ApiAnalytics';
2729
2830 $wgAutoloadClasses['ApiAnalyticsBase'] = $dir . 'ApiAnalyticsBase.php';
 31+
 32+$metricsDir = $dir . 'metrics/';
 33+
 34+$wgAutoloadClasses['ComScoreUniqueVisitorMetric'] = $metricsDir . 'ComScoreUniqueVisitorMetric.php';
 35+$wgMetricAPIModules['comscoreuniquevisitors'] = 'ComScoreUniqueVisitorMetric';
Index: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class ComScoreUniqueVisitorMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectregions',
 9+ 'selectcountries',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'Unique persons that visited one of the Wikimedia wikis at least once in a certain month';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/ComScoreUniqueVisitorMetric.php
___________________________________________________________________
Added: svn:keywords
121 + Id
Added: svn:eol-style
222 + native
Index: trunk/extensions/MetricsReporting/ApiAnalytics.php
@@ -4,20 +4,19 @@
55
66 private $metricModuleNames, $params;
77
8 - private $metricModules = array(
9 - );
10 -
118 public function __construct( $main, $action ) {
129 parent::__construct( $main, $action );
13 - $this->metricModuleNames = array_keys( $this->metricModules );
 10+ global $wgMetricAPIModules;
 11+ $this->metricModuleNames = array_keys( $wgMetricAPIModules );
1412 }
1513
1614 public function execute() {
1715 $this->params = $this->extractRequestParams();
1816
 17+ global $wgMetricAPIModules;
1918 // Instantiate requested modules
2019 $modules = array();
21 - $this->instantiateModules( $modules, 'prop', $this->mQueryPropModules );
 20+ $this->instantiateModules( $modules, 'prop', $wgMetricAPIModules );
2221
2322 // Execute all requested modules.
2423 foreach ( $modules as $module ) {
@@ -42,10 +41,11 @@
4342 }
4443
4544 public function getAllowedParams() {
 45+ global $wgMetricAPIModules;
4646 return array(
4747 'metric' => array(
4848 ApiBase::PARAM_ISMULTI => false,
49 - ApiBase::PARAM_TYPE => $this->metricModuleNames,
 49+ ApiBase::PARAM_TYPE => $wgMetricAPIModules,
5050 ApiBase::PARAM_REQUIRED => true,
5151 ),
5252 );
@@ -82,7 +82,7 @@
8383 * @return string
8484 */
8585 public function makeHelpMsg() {
86 - $msg = '';
 86+ $msg = parent::makeHelpMsg();
8787
8888 $querySeparator = str_repeat( '--- ', 12 );
8989 $moduleSeparator = str_repeat( '*** ', 14 );
@@ -90,11 +90,6 @@
9191 $msg .= $this->makeHelpMsgHelper( $this->metricModules, 'metric' );
9292 $msg .= "\n\n$moduleSeparator Modules: continuation $moduleSeparator\n\n";
9393
94 - // Perform the base call last because the $this->mAllowedGenerators
95 - // will be updated inside makeHelpMsgHelper()
96 - // Use parent to make default message for the query module
97 - $msg = parent::makeHelpMsg() . $msg;
98 -
9994 return $msg;
10095 }
10196

Status & tagging log