From dc3d2394558786c56ccb06b0360ba5b3e22bb436 Mon Sep 17 00:00:00 2001 From: Mali Akmanalp Date: Fri, 13 Apr 2018 11:42:26 -0400 Subject: [PATCH] Visualization controller now returns correct year range based on dataset. --- app/controllers/visualization.js | 18 ++++++++++++------ app/variables/data-variables.js | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/visualization.js b/app/controllers/visualization.js index 3cc738ec..df8a938f 100644 --- a/app/controllers/visualization.js +++ b/app/controllers/visualization.js @@ -24,9 +24,12 @@ export default Ember.Controller.extend({ // in question, not the first and last year of the product / industry // datasets let entityType = this.get("entityType"); - let yearRangeKey = `featureToggle.year_ranges.${entityType}.first_year`; - if (this.get(yearRangeKey) !== undefined){ - return this.get(yearRangeKey); + let datasetYearRangeKey = `featureToggle.year_ranges.${entityType}.first_year`; + let agCensusDatasets = this.get('featureToggle.agcensus_datasets'); + if (_.contains(agCensusDatasets, entityType)){ + return this.get('featureToggle.year_ranges.agcensus.first_year'); + } else if (this.get(datasetYearRangeKey) !== undefined){ + return this.get(datasetYearRangeKey); } else { return this.get("featureToggle.first_year"); } @@ -34,9 +37,12 @@ export default Ember.Controller.extend({ lastYear: computed('entityType', 'featureToggle', function(){ // See firstYear ^ let entityType = this.get("entityType"); - let yearRangeKey = `featureToggle.year_ranges.${entityType}.last_year`; - if (this.get(yearRangeKey) !== undefined){ - return this.get(yearRangeKey); + let datasetYearRangeKey = `featureToggle.year_ranges.${entityType}.last_year`; + let agCensusDatasets = this.get('featureToggle.agcensus_datasets'); + if (_.contains(agCensusDatasets, entityType)){ + return this.get('featureToggle.year_ranges.agcensus.last_year'); + } else if (this.get(datasetYearRangeKey) !== undefined){ + return this.get(datasetYearRangeKey); } else { return this.get("featureToggle.last_year"); } diff --git a/app/variables/data-variables.js b/app/variables/data-variables.js index 0f1e628e..e259cee9 100644 --- a/app/variables/data-variables.js +++ b/app/variables/data-variables.js @@ -25,6 +25,8 @@ export default { "agproduct": { "first_year": 2007, "last_year": 2015 }, "agcensus": { "first_year": 2014, "last_year": 2014 } // land use, farm type, etc }, + // These determine which datasets use the "agcensus" year range + "agcensus_datasets": ["agproduct", "livestock", "nonag", 'landUse'], "geo_center": [4.6,-74.06], "subregions" : { "country": "department",