r94894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94893‎ | r94894 | r94895 >
Date:13:58, 18 August 2011
Author:reedy
Status:deferred
Tags:
Comment:
Add GenericMetricBase for use with generic CSV import (importCSVFile.php)

Should be reasonably usable
Modified paths:
  • /trunk/extensions/MetricsReporting/GenericDataTable.sql (modified) (history)
  • /trunk/extensions/MetricsReporting/MetricsReporting.php (modified) (history)
  • /trunk/extensions/MetricsReporting/metrics/GenericMetricBase.php (added) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/MetricsReporting.php
@@ -33,6 +33,8 @@
3434
3535 $metricsDir = $dir . 'metrics/';
3636
 37+$wgAutoloadClasses['GenericMetricBase'] = $metricsDir . 'GenericMetricBase.php';
 38+
3739 $wgAutoloadClasses['ComScoreReachPercentageMetric'] = $metricsDir . 'ComScoreReachPercentageMetric.php';
3840 $wgMetricAPIModules['comscorereachpercentage'] = 'ComScoreReachPercentageMetric';
3941
Index: trunk/extensions/MetricsReporting/metrics/GenericMetricBase.php
@@ -0,0 +1,47 @@
 2+<?php
 3+
 4+/**
 5+ * Subclass this, pass the table name to the constructor, then just override
 6+ * the getDescription and getExamples functions
 7+ *
 8+ * Then add it to the loader
 9+ */
 10+abstract class GenericMetricBase extends ApiAnalyticsBase {
 11+
 12+ protected $tableName;
 13+
 14+ /**
 15+ * @param $tableName string
 16+ */
 17+ function __construct( $tableName ) {
 18+ $this->tableName = $tableName;
 19+ }
 20+
 21+ public function getAllowedFilters() {
 22+ return array(
 23+ 'selectprojects',
 24+ 'selectcountries',
 25+ );
 26+ }
 27+
 28+ protected function getQueryInfo() {
 29+ return array(
 30+ 'table' => array( $this->tableName ),
 31+ 'conds' => array(),
 32+ 'options' => array( 'GROUP BY' => 'date', 'ORDER BY' => 'date' ),
 33+ 'join_conds' => array(),
 34+ );
 35+ }
 36+
 37+ protected function getQueryFields() {
 38+ return array( 'date', 'language_code', 'project_code', 'country_code', 'value' );
 39+ }
 40+
 41+ public abstract function getDescription();
 42+
 43+ protected abstract function getExamples();
 44+
 45+ public function getVersion() {
 46+ return __CLASS__ . ': $Id$';
 47+ }
 48+}
\ No newline at end of file
Property changes on: trunk/extensions/MetricsReporting/metrics/GenericMetricBase.php
___________________________________________________________________
Added: svn:eol-style
149 + native
Added: svn:keywords
250 + Id
Index: trunk/extensions/MetricsReporting/GenericDataTable.sql
@@ -4,6 +4,6 @@
55 `project_code` varchar (10) DEFAULT NULL,
66 `country_code` varchar (3) DEFAULT NULL,
77 `value` bigint (12),-- Needs to be decimal?
8 - PRIMARY KEY (date,language_code,project_code,country_code,value),
 8+ PRIMARY KEY ( date, language_code, project_code, country_code, value ),
99 -- More indexes may be needed where language, project and country could be null
1010 ) ;
\ No newline at end of file

Status & tagging log