Yaron Koren has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316381

Change subject: Simplified calling of getTimePeriod()
......................................................................

Simplified calling of getTimePeriod()

Change-Id: Ib4c4888ec0715c87646ef8d10329f773c1097648
---
M drilldown/CargoFilter.php
1 file changed, 10 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/81/316381/2

diff --git a/drilldown/CargoFilter.php b/drilldown/CargoFilter.php
index 1573893..a0c1437 100644
--- a/drilldown/CargoFilter.php
+++ b/drilldown/CargoFilter.php
@@ -16,7 +16,7 @@
        public $allowed_values;
        public $required_filters = array();
        public $possible_applied_filters = array();
-
+       
        function __construct( $name, $tableName, $fieldDescription ) {
                $this->name = $name;
                $this->tableName = $tableName;
@@ -113,14 +113,15 @@
        function getTimePeriodValues( $appliedFilters ) {
                $possible_dates = array();
                $date_field = $this->name;
+               $timePeriod = $this->getTimePeriod( $fullTextSearchTerm, 
$appliedFilters );
 
-               if ( $this->getTimePeriod( $appliedFilters ) == 'day' ) {
+               if ( $timePeriod == 'day' ) {
                        $fields = "YEAR($date_field), MONTH($date_field), 
DAYOFMONTH($date_field)";
-               } elseif ( $this->getTimePeriod( $appliedFilters ) == 'month' ) 
{
+               } elseif ( $timePeriod == 'month' ) {
                        $fields = "YEAR($date_field), MONTH($date_field)";
-               } elseif ( $this->getTimePeriod( $appliedFilters ) == 'year' ) {
+               } elseif ( $timePeriod == 'year' ) {
                        $fields = "YEAR($date_field)";
-               } else { // if ( $this->getTimePeriod() == 'decade' ) {
+               } else { // if ( $timePeriod == 'decade' ) {
                        $fields = "YEAR($date_field)";
                }
 
@@ -132,16 +133,16 @@
                while ( $row = $cdb->fetchRow( $res ) ) {
                        if ( $row[0] == null ) {
                                $possible_dates['_none'] = $row['COUNT(*)'];
-                       } elseif ( $this->getTimePeriod( $appliedFilters ) == 
'day' ) {
+                       } elseif ( $timePeriod == 'day' ) {
                                $date_string = 
CargoDrilldownUtils::monthToString( $row[1] ) . ' ' . $row[2] . ', ' . $row[0];
                                $possible_dates[$date_string] = $row[3];
-                       } elseif ( $this->getTimePeriod( $appliedFilters ) == 
'month' ) {
+                       } elseif ( $timePeriod == 'month' ) {
                                $date_string = 
CargoDrilldownUtils::monthToString( $row[1] ) . ' ' . $row[0];
                                $possible_dates[$date_string] = $row[2];
-                       } elseif ( $this->getTimePeriod( $appliedFilters ) == 
'year' ) {
+                       } elseif ( $timePeriod == 'year' ) {
                                $date_string = $row[0];
                                $possible_dates[$date_string] = $row[1];
-                       } else { // if ( $this->getTimePeriod() == 'decade' )
+                       } else { // if ( $timePeriod == 'decade' )
                                // Unfortunately, there's no SQL DECADE()
                                // function - so we have to take these values,
                                // which are grouped into year "buckets", and

-- 
To view, visit https://gerrit.wikimedia.org/r/316381
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4c4888ec0715c87646ef8d10329f773c1097648
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to