Skip to content

Commit

Permalink
Visualization controller now returns correct year range based on
Browse files Browse the repository at this point in the history
dataset.
  • Loading branch information
makmanalp committed Apr 13, 2018
1 parent 3030f5c commit dc3d239
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/controllers/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ 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");
}
}),
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");
}
Expand Down
2 changes: 2 additions & 0 deletions app/variables/data-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dc3d239

Please sign in to comment.