Index: trunk/extensions/MetricsReporting/MetricsReporting.php |
— | — | @@ -33,6 +33,8 @@ |
34 | 34 | |
35 | 35 | $metricsDir = $dir . 'metrics/'; |
36 | 36 | |
| 37 | +$wgAutoloadClasses['GenericMetricBase'] = $metricsDir . 'GenericMetricBase.php'; |
| 38 | + |
37 | 39 | $wgAutoloadClasses['ComScoreReachPercentageMetric'] = $metricsDir . 'ComScoreReachPercentageMetric.php'; |
38 | 40 | $wgMetricAPIModules['comscorereachpercentage'] = 'ComScoreReachPercentageMetric'; |
39 | 41 | |
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 |
1 | 49 | + native |
Added: svn:keywords |
2 | 50 | + Id |
Index: trunk/extensions/MetricsReporting/GenericDataTable.sql |
— | — | @@ -4,6 +4,6 @@ |
5 | 5 | `project_code` varchar (10) DEFAULT NULL, |
6 | 6 | `country_code` varchar (3) DEFAULT NULL, |
7 | 7 | `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 ), |
9 | 9 | -- More indexes may be needed where language, project and country could be null |
10 | 10 | ) ; |
\ No newline at end of file |