Skip to content

Commit

Permalink
updated back to master version of project_helpers.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
tetrahedra committed Oct 10, 2015
1 parent 451e127 commit a2f6d49
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions helpers/project_helpers.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,6 @@ def dfid_region_projects_budget(regionCode)
end

def dfid_country_projects_data

oipaCountryProjectValuesJSON = RestClient.get "http://dfid-oipa.zz-clients.net/api/activities/aggregations?reporting_organisation=GB-1&budget_period_start=2015-04-01&budget_period_end=2016-03-31&group_by=recipient_country&aggregations=count,budget&order_by=-budget"
projectValues = JSON.parse(oipaCountryProjectValuesJSON)

# Map the input data structure so that it matches the required input for Tilestream
projectValuesMapInput = projectValues.map do |elem|
{
elem["recipient_country"]["code"] => {
"country" => elem["recipient_country"]["name"],
"id" => elem["recipient_country"]["code"],
"projects" => elem["count"],
"budget" => elem["budget"],
"flag" => '/images/flags/' + elem["recipient_country"]["code"].downcase + '.png'
}
}
end

# Edit the returned hash object so that the data is in the correct format (e.g. remove enclosing [])
projectValuesMapInput.to_s.gsub("[", "").gsub("]", "").gsub("=>",":").gsub("}}, {","},")
end


# TODO Delete this code when new map is returning values
def dfid_country_projects_data_old
result = @cms_db['projects'].aggregate([{
"$match" => {
"projectType" => "country",
Expand Down

0 comments on commit a2f6d49

Please sign in to comment.