r91124 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91123‎ | r91124 | r91125 >
Date:22:15, 29 June 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Add the rest of the example metrics
Modified paths:
  • /trunk/extensions/MetricsReporting/MetricsReporting.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpActiveEditors100Metric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php (added) (history)
  • /trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php (added) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/MetricsReporting.php
@@ -30,5 +30,29 @@
3131
3232 $metricsDir = $dir . 'metrics/';
3333
 34+$wgAutoloadClasses['ComScoreReachPercentageMetric'] = $metricsDir . 'ComScoreReachPercentageMetric.php';
 35+$wgMetricAPIModules['comscorereachpercentage'] = 'ComScoreReachPercentageMetric';
 36+
3437 $wgAutoloadClasses['ComScoreUniqueVisitorMetric'] = $metricsDir . 'ComScoreUniqueVisitorMetric.php';
3538 $wgMetricAPIModules['comscoreuniquevisitors'] = 'ComScoreUniqueVisitorMetric';
 39+
 40+$wgAutoloadClasses['DumpActiveEditors100Metric'] = $metricsDir . 'DumpActiveEditors100Metric.php';
 41+$wgMetricAPIModules['dumpactiveeditors100'] = 'DumpActiveEditors100Metric';
 42+
 43+$wgAutoloadClasses['DumpActiveEditors15Metric'] = $metricsDir . 'DumpActiveEditors15Metric.php';
 44+$wgMetricAPIModules['dumpactiveeditors15'] = 'DumpActiveEditors15Metric';
 45+
 46+$wgAutoloadClasses['DumpArticleCountMetric'] = $metricsDir . 'DumpArticleCountMetric.php';
 47+$wgMetricAPIModules['dumparticlecount'] = 'DumpArticleCountMetric';
 48+
 49+$wgAutoloadClasses['DumpBinaryCountMetric'] = $metricsDir . 'DumpBinaryCountMetric.php';
 50+$wgMetricAPIModules['dumpbinarycount'] = 'DumpBinaryCountMetric';
 51+
 52+$wgAutoloadClasses['DumpEditsMetric'] = $metricsDir . 'DumpEditsMetric.php';
 53+$wgMetricAPIModules['dumpedits'] = 'DumpEditsMetric';
 54+
 55+$wgAutoloadClasses['DumpNewRegisteredEditorsMetric'] = $metricsDir . 'DumpNewRegisteredEditorsMetric.php';
 56+$wgMetricAPIModules['dumpnewregisterededitors'] = 'DumpNewRegisteredEditorsMetric';
 57+
 58+$wgAutoloadClasses['SquidPageViewsMetric'] = $metricsDir . 'SquidPageViewsMetric.php';
 59+$wgMetricAPIModules['squidpageviews'] = 'SquidPageViewsMetric';
Index: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpNewRegisteredEditorsMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All registered editors that in a certain month for the first time crossed the threshold of 10 edits since signing up';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpNewRegisteredEditorsMetric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class ComScoreReachPercentageMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectregions',
 9+ 'selectcountries',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'Percentage of total unique visitors to any web property which also visited a Wikimedia wiki';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/ComScoreReachPercentageMetric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors100Metric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpActiveEditors100Metric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All registered editors that made 100 or more edits in a certain month';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors100Metric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpEditsMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All edits on articles (as defined by dumparticlecount)';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpEditsMetric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpActiveEditors15Metric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All registered editors that made 5 or more edits in a certain month';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpActiveEditors5Metric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
@@ -0,0 +1,20 @@
 2+<?php
 3+
 4+class SquidPageViewsMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ );
 9+ }
 10+
 11+ public function getDescription() {
 12+ return array(
 13+ 'Total articles (htm component) requested from nearly all Wikimedia wikis (exceptions are mostly special purpose wikis, e.g. wikimania wikis)',
 14+ 'Totals are based on the archived 1:1000 sampled squid logs.',
 15+ );
 16+ }
 17+
 18+ public function getVersion() {
 19+ return __CLASS__ . ': $Id$';
 20+ }
 21+}
Property changes on: trunk/extensions/MetricsReporting/metrics/SquidPageViewsMetric.php
___________________________________________________________________
Added: svn:eol-style
122 + native
Added: svn:keywords
223 + Id
Index: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpArticleCountMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All namespace 0 pages which contain an internal link minus redirect pages (for some projects extra namespaces qualify)';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpArticleCountMetric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id
Index: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+class DumpBinaryCountMetric extends ApiAnalyticsBase {
 5+
 6+ public function getAllowedFilters() {
 7+ return array(
 8+ 'selectprojects',
 9+ 'selectwikis',
 10+ );
 11+ }
 12+
 13+ public function getDescription() {
 14+ return 'All binary files (nearly all of which are multimedia files) available for download/article inclusion on a wiki';
 15+ }
 16+
 17+ public function getVersion() {
 18+ return __CLASS__ . ': $Id$';
 19+ }
 20+}
Property changes on: trunk/extensions/MetricsReporting/metrics/DumpBinaryCountMetric.php
___________________________________________________________________
Added: svn:eol-style
121 + native
Added: svn:keywords
222 + Id

Comments

#Comment by Hashar (talk | contribs)   12:01, 30 June 2011

In MetricsReporting.php you really want to automatically detect metrics by looking for PHP files ending with 'Metric.php'. Would make things way easier to handle. Something like:

$metricsDir = $dir . 'metrics/';
$names = preg_match_all( "(\w+)Metric\.php",
 scandir( $metricsDir )
);

Then iterates over the $names array:

foreach( $names as $name ) {
  $metric = "{$name}Metric";
  $wgAutoloadClasses[$metric] = $metricsDir . "{$metric}.php";
  $wgMetricAPIModules[strtolower($metric)] = $metric;
}
#Comment by Reedy (talk | contribs)   16:21, 30 June 2011

Maybe, maybe not, but it didn't need a fixme for that. I don't think there's anywhere in MW that does dynamic loading like that.

Doing it explicitally is easier for testing works for me, it might be changed later, but repeated scans of directories etc I'm guessing would be slower, and by the time I've put the effort in for the above, and I know it'll work. There will be others added later.

Simiarily, a wrapper function passed an array of files could've been done

#Comment by Hashar (talk | contribs)   18:57, 30 June 2011

The fixme was merely to attract your attention :))))))) I agree a wrapper array is a better idea, would save the scandir().

Status & tagging log