Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit dc3d239

Browse files
committed
Visualization controller now returns correct year range based on
dataset.
1 parent 3030f5c commit dc3d239

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

app/controllers/visualization.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,25 @@ export default Ember.Controller.extend({
2424
// in question, not the first and last year of the product / industry
2525
// datasets
2626
let entityType = this.get("entityType");
27-
let yearRangeKey = `featureToggle.year_ranges.${entityType}.first_year`;
28-
if (this.get(yearRangeKey) !== undefined){
29-
return this.get(yearRangeKey);
27+
let datasetYearRangeKey = `featureToggle.year_ranges.${entityType}.first_year`;
28+
let agCensusDatasets = this.get('featureToggle.agcensus_datasets');
29+
if (_.contains(agCensusDatasets, entityType)){
30+
return this.get('featureToggle.year_ranges.agcensus.first_year');
31+
} else if (this.get(datasetYearRangeKey) !== undefined){
32+
return this.get(datasetYearRangeKey);
3033
} else {
3134
return this.get("featureToggle.first_year");
3235
}
3336
}),
3437
lastYear: computed('entityType', 'featureToggle', function(){
3538
// See firstYear ^
3639
let entityType = this.get("entityType");
37-
let yearRangeKey = `featureToggle.year_ranges.${entityType}.last_year`;
38-
if (this.get(yearRangeKey) !== undefined){
39-
return this.get(yearRangeKey);
40+
let datasetYearRangeKey = `featureToggle.year_ranges.${entityType}.last_year`;
41+
let agCensusDatasets = this.get('featureToggle.agcensus_datasets');
42+
if (_.contains(agCensusDatasets, entityType)){
43+
return this.get('featureToggle.year_ranges.agcensus.last_year');
44+
} else if (this.get(datasetYearRangeKey) !== undefined){
45+
return this.get(datasetYearRangeKey);
4046
} else {
4147
return this.get("featureToggle.last_year");
4248
}

app/variables/data-variables.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default {
2525
"agproduct": { "first_year": 2007, "last_year": 2015 },
2626
"agcensus": { "first_year": 2014, "last_year": 2014 } // land use, farm type, etc
2727
},
28+
// These determine which datasets use the "agcensus" year range
29+
"agcensus_datasets": ["agproduct", "livestock", "nonag", 'landUse'],
2830
"geo_center": [4.6,-74.06],
2931
"subregions" : {
3032
"country": "department",

0 commit comments

Comments
 (0)