Currently we derive the region type (for some reason called group) for datasets by checking the first letters of thegeo_id. Adding more and more region types has caused this if/else method to grow:
def group
if geo_id.start_with?('GM', 'BEGM', 'DKGM')
'municipality'
elsif geo_id.start_with?('WK')
'district'
elsif geo_id.start_with?('BU', 'BEBU')
'neighbourhood'
elsif geo_id.start_with?('RG')
'region'
elsif entso_data_source? || geo_id.start_with?('UKNI') || geo_id.start_with?('GB')
'country'
elsif geo_id.start_with?('RES', 'ES')
'res'
else
'province'
end
end
in models/dataset.rb.
It would be better to define a new attribute on Dataset, where users can set the region type explicitly. And available region types could be validated through Atlas.
Currently we derive the region type (for some reason called
group) for datasets by checking the first letters of thegeo_id. Adding more and more region types has caused thisif/elsemethod to grow:in
models/dataset.rb.It would be better to define a new attribute on
Dataset, where users can set the region type explicitly. And available region types could be validated throughAtlas.