Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/acp regions #342

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = develop
branch = acp-regions
2 changes: 1 addition & 1 deletion db
81 changes: 81 additions & 0 deletions lib/data/seeds/biopama_countries.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
iso3,acp_region
ATG,caribbean
BHS,caribbean
BLZ,caribbean
BRB,caribbean
CUB,caribbean
DMA,caribbean
DOM,caribbean
GRD,caribbean
GUY,caribbean
HTI,caribbean
JAM,caribbean
KNA,caribbean
LCA,caribbean
SUR,caribbean
TTO,caribbean
VCT,caribbean
BDI,central_africa
CAF,central_africa
CMR,central_africa
COD,central_africa
COG,central_africa
GAB,central_africa
GNQ,central_africa
STP,central_africa
TCD,central_africa
DJI,eastern_africa
ERI,eastern_africa
ETH,eastern_africa
KEN,eastern_africa
RWA,eastern_africa
SDN,eastern_africa
SOM,eastern_africa
SSD,eastern_africa
TZA,eastern_africa
UGA,eastern_africa
AGO,southern_africa
BWA,southern_africa
COM,southern_africa
LSO,southern_africa
MDG,southern_africa
MOZ,southern_africa
MWI,southern_africa
MUS,southern_africa
NAM,southern_africa
SWZ,southern_africa
SYC,southern_africa
ZAF,southern_africa
ZMB,southern_africa
ZWE,southern_africa
BEN,western_africa
BFA,western_africa
CIV,western_africa
CPV,western_africa
GHA,western_africa
GIN,western_africa
GMB,western_africa
GNB,western_africa
LBR,western_africa
MLI,western_africa
MRT,western_africa
NER,western_africa
NGA,western_africa
SEN,western_africa
SLE,western_africa
TGO,western_africa
WSM,pacific
PLW,pacific
SLB,pacific
PNG,pacific
FJI,pacific
NRU,pacific
NIU,pacific
TON,pacific
TUV,pacific
COK,pacific
MHL,pacific
VUT,pacific
KIR,pacific
FSM,pacific
TLS,pacific
80 changes: 0 additions & 80 deletions lib/data/seeds/biopama_countries_iso_codes.csv

This file was deleted.

14 changes: 6 additions & 8 deletions lib/modules/wdpa/biopama_countries_importer.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
module Wdpa::BiopamaCountriesImporter
BIOPAMA_COUNTRIES_CSV = "#{Rails.root}/lib/data/seeds/biopama_countries_iso_codes.csv"
BIOPAMA_COUNTRIES_CSV = "#{Rails.root}/lib/data/seeds/biopama_countries.csv"
extend self

def import
ActiveRecord::Base.transaction do
csv = CSV.read(BIOPAMA_COUNTRIES_CSV)
csv.shift # remove headers

csv.each do |row|
iso = row[0]
CSV.foreach(BIOPAMA_COUNTRIES_CSV, headers: true) do |row|
iso = row['iso3']
region = row['acp_region']
country = Country.find_by_iso_3(iso)
if country
country.update_attributes(is_biopama: true)
puts "#{country.name} has been flagged as BIOPAMA country"
country.update_attributes(acp_region: region)
puts "#{country.name} has been flagged as an ACP country"
else
puts "Country with iso_3 #{iso} does not exist"
end
Expand Down