Index: trunk/wikistats/MetricsReporting/MetricsReporting.php |
— | — | @@ -1,4 +1,4 @@ |
2 | | -<?php |
| 2 | +<?php |
3 | 3 | |
4 | 4 | $wgeAnalyticsFieldNames = array( |
5 | 5 | 'select_regions' => "REGION", |
— | — | @@ -34,9 +34,9 @@ |
35 | 35 | "US" => "United States", |
36 | 36 | "W" => "World", |
37 | 37 | ), |
38 | | -//"select_countries" => array(), |
39 | | -//"select_web_properties"=> array(), |
40 | | -"select_projects"=> array( |
| 38 | +// "select_countries" => array(), |
| 39 | +// "select_web_properties"=> array(), |
| 40 | +"select_projects" => array( |
41 | 41 | "wb" => "Wikibooks", |
42 | 42 | "wk" => "Wiktionary", |
43 | 43 | "wn" => "Wikinews", |
— | — | @@ -45,19 +45,19 @@ |
46 | 46 | "ws" => "Wikisource", |
47 | 47 | "wv" => "Wikiversity", |
48 | 48 | "co" => "Commons", |
49 | | - "wx" => "Other projects", |
| 49 | + "wx" => "Other projects", |
50 | 50 | ), |
51 | | -//"select_wikis"=> array(), |
52 | | -"select_editors"=> array( |
| 51 | +// "select_wikis"=> array(), |
| 52 | +"select_editors" => array( |
53 | 53 | "A" => "Anonymous", |
54 | 54 | "R" => "Registered User", |
55 | 55 | "B" => "Bot", |
56 | 56 | ), |
57 | | -"select_edits"=> array( |
| 57 | +"select_edits" => array( |
58 | 58 | "M" => "Manual", |
59 | 59 | "B" => "Bot", |
60 | 60 | ), |
61 | | -"select_platform"=> array( |
| 61 | +"select_platform" => array( |
62 | 62 | "M" => "Moblie", |
63 | 63 | "N" => "Non-Mobile", |
64 | 64 | ), |
— | — | @@ -70,13 +70,13 @@ |
71 | 71 | $wgAutoloadClasses['MetricsReportingQuery'] = $dir . '/MetricsReportingQuery.php'; |
72 | 72 | |
73 | 73 | $wgeAnalyticsMetricsList = array(); |
74 | | -$metricsdir = $dir."/metrics"; |
75 | | -$dh = opendir($metricsdir); |
76 | | -while( ($file = readdir($dh)) !== false){ |
77 | | - if(filetype($metricsdir."/".$file) == "file" ){ |
78 | | - $file_path_parts = pathinfo($metricsdir."/".$file); |
79 | | - if($file_path_parts['extension'] == 'php'){ |
80 | | - $wgAutoloadClasses["ApiAnalyticsMetric{$file_path_parts['filename']}"] = $metricsdir."/".$file; |
| 74 | +$metricsdir = $dir . "/metrics"; |
| 75 | +$dh = opendir( $metricsdir ); |
| 76 | +while ( ( $file = readdir( $dh ) ) !== false ) { |
| 77 | + if ( filetype( $metricsdir . "/" . $file ) == "file" ) { |
| 78 | + $file_path_parts = pathinfo( $metricsdir . "/" . $file ); |
| 79 | + if ( $file_path_parts['extension'] == 'php' ) { |
| 80 | + $wgAutoloadClasses["ApiAnalyticsMetric{$file_path_parts['filename']}"] = $metricsdir . "/" . $file; |
81 | 81 | $wgeAnalyticsMetricsList[] = $file_path_parts['filename']; |
82 | 82 | } |
83 | 83 | } |
— | — | @@ -90,9 +90,9 @@ |
91 | 91 | function wfAnalyticsMetricConnection() { |
92 | 92 | global $wgeAnalyticsMetricDBserver, $wgeAnalyticsMetricDBname; |
93 | 93 | global $wgeAnalyticsMetricDBuser, $wgeAnalyticsMetricDBpassword; |
94 | | - |
| 94 | + |
95 | 95 | static $db; |
96 | | - |
| 96 | + |
97 | 97 | if ( !$db ) { |
98 | 98 | $db = new DatabaseMysql( |
99 | 99 | $wgeAnalyticsMetricDBserver, |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | $wgeAnalyticsMetricDBname ); |
103 | 103 | $db->query( "SET names utf8" ); |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | return $db; |
107 | 107 | } |
108 | | - |
| 108 | + |
Index: trunk/wikistats/MetricsReporting/metrics/comscore_reach_percentage.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | | - |
4 | | -class ApiAnalyticsMetriccomscore_reach_percentage extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 3 | + |
| 4 | +class ApiAnalyticsMetriccomscore_reach_percentage extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "comscore_reach_percentage"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_regions", "select_countries"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_regions", "select_countries" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_active_editors_100.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_active_editors_100 extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_active_editors_100 extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_active_editors_100"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_active_editors_5.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_active_editors_5 extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_active_editors_5 extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_active_editors_5"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_edits.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_edits extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_edits extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_active_edits"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/squid_page_views.php |
— | — | @@ -1,17 +1,17 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricsquid_page_views extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricsquid_page_views extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "squid_page_views"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_regions", "select_countries", "select_web_properties", "select_projects", "select_wikis", "select_platform" |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_regions", "select_countries", "select_web_properties", "select_projects", "select_wikis", "select_platform" |
13 | 13 | ); |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | } |
17 | 17 | |
18 | | -//Any additions go here |
\ No newline at end of file |
| 18 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_article_count.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_article_count extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_article_count extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_article_count"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_binary_count.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_binary_count extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_binary_count extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_binary_count"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/dump_new_registered_editors.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class ApiAnalyticsMetricdump_new_registered_editors extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +class ApiAnalyticsMetricdump_new_registered_editors extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "dump_new_registered_editors"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_projects", "select_wikis"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_projects", "select_wikis" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/metrics/comscore_unique_visotors.php |
— | — | @@ -1,16 +1,16 @@ |
2 | 2 | <?php |
3 | | - |
4 | | -class ApiAnalyticsMetriccomscore_unique_visitors extends ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 3 | + |
| 4 | +class ApiAnalyticsMetriccomscore_unique_visitors extends ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = true; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = "comscore_unique_visitors"; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
12 | | - return array("select_regions", "select_countries"); |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
| 12 | + return array( "select_regions", "select_countries" ); |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | } |
16 | 16 | |
17 | | -//Any additions go here |
\ No newline at end of file |
| 17 | +// Any additions go here |
\ No newline at end of file |
Index: trunk/wikistats/MetricsReporting/api/ApiAnalytics.php |
— | — | @@ -7,146 +7,145 @@ |
8 | 8 | |
9 | 9 | |
10 | 10 | class ApiAnalytics extends ApiBase { |
11 | | - |
| 11 | + |
12 | 12 | public function execute() { |
13 | | - |
| 13 | + |
14 | 14 | global $wgeAnalyticsMetricsList, $wgeAnalyticsFieldReturns; |
15 | 15 | $params = $this->extractRequestParams(); |
16 | 16 | $result = $this->getResult(); |
17 | 17 | |
18 | | - foreach($wgeAnalyticsMetricsList as $metricName){ |
19 | | - //find the metric requested |
20 | | - if($metricName == $params["metric"]){ |
21 | | - |
22 | | - //instantiate the class and an empty array of metricsreportingquery objects |
| 18 | + foreach ( $wgeAnalyticsMetricsList as $metricName ) { |
| 19 | + // find the metric requested |
| 20 | + if ( $metricName == $params["metric"] ) { |
| 21 | + |
| 22 | + // instantiate the class and an empty array of metricsreportingquery objects |
23 | 23 | $metricClassName = "ApiAnalyticsMetric$metricName"; |
24 | 24 | $metric = new $metricClassName; |
25 | 25 | $filterParams = $metric->getAllowedFilterParams(); |
26 | 26 | $queries = array(); |
27 | | - |
28 | | - //check to see which filters are set |
29 | | - foreach($filterParams as $filterParam){ |
30 | | - if(isset( $params["$filterParam"])){ |
31 | | - $filter_results = $this->collectQueryFilters($filterParam, $params["$filterParam"]); |
32 | | - |
33 | | - //if multiple results returned, merge each of the query objects with whatever exists |
34 | | - if (count($filter_results) > 1){ |
35 | | - foreach ($filter_results as $result){ |
36 | | - foreach ($queries as $queryObj){ |
37 | | - $result->merge($queryObj); |
| 27 | + |
| 28 | + // check to see which filters are set |
| 29 | + foreach ( $filterParams as $filterParam ) { |
| 30 | + if ( isset( $params["$filterParam"] ) ) { |
| 31 | + $filter_results = $this->collectQueryFilters( $filterParam, $params["$filterParam"] ); |
| 32 | + |
| 33 | + // if multiple results returned, merge each of the query objects with whatever exists |
| 34 | + if ( count( $filter_results ) > 1 ) { |
| 35 | + foreach ( $filter_results as $result ) { |
| 36 | + foreach ( $queries as $queryObj ) { |
| 37 | + $result->merge( $queryObj ); |
38 | 38 | } |
39 | 39 | } |
40 | | - $queries = $filter_results; |
41 | | - } |
42 | | - //else just merge with the only object |
43 | | - else{ |
44 | | - foreach($queries as &$queryObj){ |
45 | | - $queryObj->merge($filter_results[0]); |
| 40 | + $queries = $filter_results; |
| 41 | + } else { |
| 42 | + // else just merge with the only object |
| 43 | + foreach ( $queries as &$queryObj ) { |
| 44 | + $queryObj->merge( $filter_results[0] ); |
46 | 45 | } |
47 | 46 | } |
48 | | - } //endif |
49 | | - }//end filters |
50 | | - |
51 | | - //calculate time |
52 | | - $range = " DATE = {$params["months"]}"; //TODO: query |
| 47 | + } // endif |
| 48 | + }// end filters |
| 49 | + |
| 50 | + // calculate time |
| 51 | + $range = " DATE = {$params["months"]}"; // TODO: query |
53 | 52 | $minDate = $params["months"]; |
54 | | - if(strpos($params["months"],";") !== FALSE){ |
55 | | - $rangeVals = explode($params["months"], ";"); |
| 53 | + if ( strpos( $params["months"], ";" ) !== FALSE ) { |
| 54 | + $rangeVals = explode( $params["months"], ";" ); |
56 | 55 | $range = " DATE >= $rangeVals[0] AND DATE <= $rangeVals[1]"; |
57 | 56 | $minDate = $rangeVals[0]; |
58 | 57 | } |
59 | 58 | $timeStart = 0; |
60 | | - if(($timeStart = strtotime($str)) !== false){ |
61 | | - $result->addValue("","timeStart",strfmttime("%Y%m%d%H%M%S",$timeStart)); |
| 59 | + if ( ( $timeStart = strtotime( $str ) ) !== false ) { |
| 60 | + $result->addValue( "", "timeStart", strfmttime( "%Y%m%d%H%M%S", $timeStart ) ); |
62 | 61 | } |
63 | | - |
64 | | - //foreach query |
65 | | - foreach($queries as &$queryObj){ |
| 62 | + |
| 63 | + // foreach query |
| 64 | + foreach ( $queries as &$queryObj ) { |
66 | 65 | $queryObj->query = $queryObj->query . " AND " . $range; |
67 | | - |
68 | | - foreach($queryObj->queryProperties as $filterName => $filterVal){ |
69 | | - $result->addValue("", $filterName, $filterVal); //filters |
| 66 | + |
| 67 | + foreach ( $queryObj->queryProperties as $filterName => $filterVal ) { |
| 68 | + $result->addValue( "", $filterName, $filterVal ); // filters |
70 | 69 | } |
71 | | - |
72 | | - if($metric->canBeNormalized){ |
73 | | - //TODO: modify queries for normalization |
74 | | - if(isset($params["normalized"]) && (strpos($params["normalized"], "true") !== FALSE)){ |
75 | | - //is normalized |
76 | | - $result->addValue("","normalized","true"); |
| 70 | + |
| 71 | + if ( $metric->canBeNormalized ) { |
| 72 | + // TODO: modify queries for normalization |
| 73 | + if ( isset( $params["normalized"] ) && ( strpos( $params["normalized"], "true" ) !== FALSE ) ) { |
| 74 | + // is normalized |
| 75 | + $result->addValue( "", "normalized", "true" ); |
77 | 76 | } else { |
78 | | - $result->addValue("","normalized","false"); |
| 77 | + $result->addValue( "", "normalized", "false" ); |
79 | 78 | } |
80 | | - |
81 | | - |
82 | | - if(isset($params["modailty"]) && (strpos($params["modality"], "indexed") !== FALSE)){ |
83 | | - //modify query for indexed |
84 | | - $result->addValue("","modality","indexed"); |
| 79 | + |
| 80 | + |
| 81 | + if ( isset( $params["modailty"] ) && ( strpos( $params["modality"], "indexed" ) !== FALSE ) ) { |
| 82 | + // modify query for indexed |
| 83 | + $result->addValue( "", "modality", "indexed" ); |
85 | 84 | } |
86 | | - |
| 85 | + |
87 | 86 | } |
88 | | - |
| 87 | + |
89 | 88 | } |
90 | | - |
| 89 | + |
91 | 90 | $language = $params["report_language"]; |
92 | | - |
| 91 | + |
93 | 92 | $dbr = wfAnalyticsMetricConnection(); |
94 | | - //TODO: build return object from queries |
95 | | - |
| 93 | + // TODO: build return object from queries |
| 94 | + |
96 | 95 | } |
97 | 96 | } |
98 | 97 | } |
99 | 98 | |
100 | 99 | |
101 | | - //override with vars for individual metrics |
102 | | - protected function collectQueryFilters($field, $fieldVal){ |
| 100 | + // override with vars for individual metrics |
| 101 | + protected function collectQueryFilters( $field, $fieldVal ) { |
103 | 102 | global $wgeAnalyticsFieldNames; |
104 | | - |
105 | | - //get rid of any potential whitespace |
106 | | - $param = preg_replace('/\s\s+/', '', $fieldVal); |
107 | | - $returnQueries = array(new MetricsReportingQuery); |
108 | | - |
109 | | - if(!isset ($wgeAnalyticsFieldNames["$field"]) ){ |
| 103 | + |
| 104 | + // get rid of any potential whitespace |
| 105 | + $param = preg_replace( '/\s\s+/', '', $fieldVal ); |
| 106 | + $returnQueries = array( new MetricsReportingQuery ); |
| 107 | + |
| 108 | + if ( !isset ( $wgeAnalyticsFieldNames["$field"] ) ) { |
110 | 109 | return $returnQueries; |
111 | 110 | } |
112 | | - |
| 111 | + |
113 | 112 | $fieldName = $wgeAnalyticsFieldNames["$field"]; |
114 | | - |
115 | | - $sub_queries = explode(",", $param); |
116 | | - foreach($sub_queries as $sub_query){ |
| 113 | + |
| 114 | + $sub_queries = explode( ",", $param ); |
| 115 | + foreach ( $sub_queries as $sub_query ) { |
117 | 116 | $topval = 0; |
118 | | - if(strpos($sub_query,"top:") !== FALSE){ |
119 | | - $topval = (int) substr($sub_query, strpos($sub_query,"top:") + 4); |
| 117 | + if ( strpos( $sub_query, "top:" ) !== FALSE ) { |
| 118 | + $topval = (int) substr( $sub_query, strpos( $sub_query, "top:" ) + 4 ); |
120 | 119 | } |
121 | | - |
122 | | - if(strpos($sub_query,"+") !== FALSE ){ |
123 | | - $and_params = explode("+", $sub_query); |
124 | | - foreach($and_params as $and_param){ |
125 | | - $this->validate_atomic_param($and_param, $field); |
126 | | - } |
127 | | - $returnQueries[] = new MetricsReportingQuery("$filedName = $sub_query ", |
128 | | - $fieldName,$sub_query);; //TODO: This is not what the query means |
| 120 | + |
| 121 | + if ( strpos( $sub_query, "+" ) !== FALSE ) { |
| 122 | + $and_params = explode( "+", $sub_query ); |
| 123 | + foreach ( $and_params as $and_param ) { |
| 124 | + $this->validate_atomic_param( $and_param, $field ); |
| 125 | + } |
| 126 | + $returnQueries[] = new MetricsReportingQuery( "$filedName = $sub_query ", |
| 127 | + $fieldName, $sub_query ); ; // TODO: This is not what the query means |
129 | 128 | } |
130 | | - else{ |
131 | | - if(!$topval){ |
132 | | - //TODO:check for {project}:{lang} (ie wp:en) style here |
133 | | - |
134 | | - $this->validate_atomic_param($sub_query, $field); |
135 | | - $returnQueries[] = new MetricsReportingQuery("$fieldName = $sub_query ", //TODO: this might be what this query means |
136 | | - $fieldName, $sub_query); |
| 129 | + else { |
| 130 | + if ( !$topval ) { |
| 131 | + // TODO:check for {project}:{lang} (ie wp:en) style here |
| 132 | + |
| 133 | + $this->validate_atomic_param( $sub_query, $field ); |
| 134 | + $returnQueries[] = new MetricsReportingQuery( "$fieldName = $sub_query ", // TODO: this might be what this query means |
| 135 | + $fieldName, $sub_query ); |
137 | 136 | } |
138 | | - else{ |
139 | | - $returnQueries[] = new MetricsReportingQuery("$fieldName < $topval", //TODO: This is not what this query means |
140 | | - $fieldName, $topval); |
| 137 | + else { |
| 138 | + $returnQueries[] = new MetricsReportingQuery( "$fieldName < $topval", // TODO: This is not what this query means |
| 139 | + $fieldName, $topval ); |
141 | 140 | } |
142 | 141 | } |
143 | 142 | } |
144 | 143 | return $returnQueries; |
145 | 144 | } |
146 | | - |
147 | | - protected function validate_atomic_param($param, $field){ |
| 145 | + |
| 146 | + protected function validate_atomic_param( $param, $field ) { |
148 | 147 | global $wgeAnalyticsValidParams; |
149 | | - if(isset($wgeAnalyticsValidParams["$field"]) && count($wgeAnalyticsValidParams["$field"]) > 0){ |
150 | | - if(count( array_keys($wgeAnalyticsValidParams["$field"], $param) ) > 0){ |
| 148 | + if ( isset( $wgeAnalyticsValidParams["$field"] ) && count( $wgeAnalyticsValidParams["$field"] ) > 0 ) { |
| 149 | + if ( count( array_keys( $wgeAnalyticsValidParams["$field"], $param ) ) > 0 ) { |
151 | 150 | return true; |
152 | 151 | } else { |
153 | 152 | return false; |
— | — | @@ -158,4 +157,4 @@ |
159 | 158 | public function getVersion() { |
160 | 159 | return __CLASS__ . ': $Id$'; |
161 | 160 | } |
162 | | -} |
\ No newline at end of file |
| 161 | +} |
Index: trunk/wikistats/MetricsReporting/api/ApiAnalyticsMetric.php |
— | — | @@ -1,18 +1,18 @@ |
2 | | -<?php |
| 2 | +<?php |
3 | 3 | |
4 | | -abstract class ApiAnalyticsMetric{ |
5 | | - |
6 | | - |
| 4 | +abstract class ApiAnalyticsMetric { |
| 5 | + |
| 6 | + |
7 | 7 | protected $canBeNormalized = false; |
8 | | - |
| 8 | + |
9 | 9 | protected $name = null; |
10 | | - |
11 | | - protected function getAllowedFilterParams(){ |
| 10 | + |
| 11 | + protected function getAllowedFilterParams() { |
12 | 12 | return array(); |
13 | 13 | } |
14 | | - |
15 | | - |
16 | | - |
| 14 | + |
| 15 | + |
| 16 | + |
17 | 17 | } |
18 | 18 | |
19 | 19 | |
Index: trunk/wikistats/MetricsReporting/MetricsReportingQuery.php |
— | — | @@ -1,19 +1,19 @@ |
2 | 2 | <?php |
3 | | -class MetricsReportingQuery{ |
4 | | - |
| 3 | +class MetricsReportingQuery { |
| 4 | + |
5 | 5 | public $query = ""; |
6 | 6 | public $queryProperties = array(); |
7 | | - |
8 | | - public function __construct(){ |
| 7 | + |
| 8 | + public function __construct() { |
9 | 9 | } |
10 | 10 | |
11 | | - public function __construct($initial_query, $initial_prop_name, $initial_prop_value){ |
| 11 | + public function __construct( $initial_query, $initial_prop_name, $initial_prop_value ) { |
12 | 12 | $this->query = $initial_query; |
13 | | - $this->queryProperties = array($initial_prop_name => $initial_prop_value); |
| 13 | + $this->queryProperties = array( $initial_prop_name => $initial_prop_value ); |
14 | 14 | } |
15 | | - |
16 | | - public function mergeWith(MetricsReportingQuery $queryObj){ |
17 | | - $this->query = $this->query.$queryObj->query; |
18 | | - $this->queryProperties = array_merge($this->queryProperties, $queryObj->queryProperties); |
| 15 | + |
| 16 | + public function mergeWith( MetricsReportingQuery $queryObj ) { |
| 17 | + $this->query = $this->query . $queryObj->query; |
| 18 | + $this->queryProperties = array_merge( $this->queryProperties, $queryObj->queryProperties ); |
19 | 19 | } |
20 | 20 | } |
\ No newline at end of file |