Skip to content

Commit

Permalink
Merge branch 'release-2.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
drewpotter committed Jul 18, 2019
2 parents 2d11d96 + e62c365 commit bba704c
Show file tree
Hide file tree
Showing 6 changed files with 28,203 additions and 28,202 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "db"]
path = db
url = https://github.com/unepwcmc/protectedplanet-db.git
branch = master
branch = develop
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.5.1

* Add new url functionality for the PAME importer and fix the restricted PAME Evaluations.

### 2.5.0

* Add and populate boolean column for countries to flag the ACP (BIOPAMA) related ones
Expand Down
56,334 changes: 28,167 additions & 28,167 deletions lib/data/seeds/pame_data-2019-07-11.csv

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions lib/modules/wdpa/pame_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ def self.import(csv_file=nil)
csv_file = csv_file || PAME_EVALUATIONS

CSV.foreach(csv_file, headers: true) do |row|
id = row[0].to_i
wdpa_id = row[1].to_i
methodology = row[3]
year = row[4].to_i
protected_area = ProtectedArea.find_by_wdpa_id(wdpa_id) || nil
metadata_id = row[6].to_i
name = row[7]
url = row[5]
restricted = row[13] == "FALSE" ? false : true
id = row[0].to_i
wdpa_id = row[1].to_i
methodology = row[3]
year = row[4].to_i
protected_area = ProtectedArea.find_by_wdpa_id(wdpa_id) || nil
metadata_id = row[6].to_i
name = row[7]
url = row[5]
restricted = row[13] == "FALSE" ? false : true
assessment_is_public = row[14] == "FALSE" ? false : true

if assessment_is_public
url = url.blank? ? "Not currently public" : url
else
url = "Not reported"
end

iso3s = row[2]
visible = false
pame_source = PameSource.where({
data_title: row[9],
resp_party: row[10],
Expand All @@ -36,11 +43,6 @@ def self.import(csv_file=nil)
ps.language = row[12]
end

# If PameEvaluation does not have a PA and is not restricted it should be hidden, so visible = false
if (protected_area.nil? && restricted) || protected_area.present?
visible = true
end

pame_evaluation = PameEvaluation.where({
id: id,
protected_area: protected_area,
Expand All @@ -52,22 +54,20 @@ def self.import(csv_file=nil)
restricted: restricted
}).first_or_create do |pe|
# If the record doesn't exist, create it...
pe.id = id
pe.protected_area = protected_area
pe.methodology = methodology
pe.year = year
pe.metadata_id = metadata_id
pe.url = url
pe.pame_source = pame_source
pe.restricted = restricted
pe.wdpa_id = wdpa_id
pe.name = name
pe.visible = visible
pe.id = id
pe.protected_area = protected_area
pe.methodology = methodology
pe.year = year
pe.metadata_id = metadata_id
pe.url = url
pe.pame_source = pame_source
pe.restricted = restricted
pe.wdpa_id = wdpa_id
pe.name = name
pe.assessment_is_public = assessment_is_public
end
if visible == false
if protected_area.nil?
hidden_evaluations << wdpa_id
end
if protected_area.nil? && restricted
countries = []
iso3s.split(",").each do |iso3|
country = Country.find_by(iso_3: iso3)
Expand Down
5 changes: 1 addition & 4 deletions test/unit/wdpa/pame_importer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,5 @@ class TestPameImporter < ActiveSupport::TestCase

pame_evaluations = PameEvaluation.all
assert_equal 9, pame_evaluations.count

hidden_pame_evaluation = PameEvaluation.find(64)
assert_equal false, hidden_pame_evaluation.visible
end
end
end

0 comments on commit bba704c

Please sign in to comment.