Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Reverts misplaced changes and adds fetching indicators from data source
Browse files Browse the repository at this point in the history
  • Loading branch information
simaob committed Oct 26, 2017
1 parent 45468d9 commit fd48b3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/data_portal_downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def download_params
{area_ids: []},
{years: []},
{units: []},
{indicator_ids: []},
{widget_ids: []},
{thresholds: []},
:json,
:pivot
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index

def download_params
params.permit(:iso, :id_1, :area, :start_year, :end_year,
units: [], widget_ids: [], thresholds: [])
units: [], indicator_ids: [], thresholds: [])
end
end
end
8 changes: 7 additions & 1 deletion app/models/data_portal_download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ def initialize options
@jurisdiction_ids = options[:jurisdiction_ids] || []
@area_ids = options[:area_ids] || []
@years = options[:years] || []
@indicator_ids = options[:indicator_ids] || []
@indicator_ids = if options[:widget_ids]
options[:widget_ids].map do |widget_id|
Widget.find(widget_id).indicators.map{ |i| i["id"] }
end.flatten
else
[]
end
@thresholds = options[:thresholds] || []
@json = options[:json]
@pivot = options[:pivot]
Expand Down
4 changes: 1 addition & 3 deletions app/models/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def initialize options
@start_year = options[:start_year]
@end_year = options[:end_year]
@units = options[:units]
@indicator_ids = options[:widget_ids].map do |widget_id|
Widget.find(widget_id).indicators.map{ |i| i["id"] }
end.flatten
@indicator_ids = options[:indicator_ids]
@thresholds = options[:thresholds]
end

Expand Down

0 comments on commit fd48b3f

Please sign in to comment.