Skip to content

Commit

Permalink
Merge branch 'release-4.8.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomarrocoli committed Apr 27, 2022
2 parents eaa9bf3 + c2d725b commit a6011f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 4.8.9
- Revert bug 'fix', downloads now look in the most recent bucket again.

### 4.8.8

- Chore: April 2022 WDPA Release
Expand Down
15 changes: 2 additions & 13 deletions lib/modules/wdpa/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ def current_wdpa_identifier
private

def current_wdpa
# This uses the release date constants in config/initializers/constants.rb to
# find the S3 bucket associated with the current release, and return it.
# If it doesn't find a bucket with the constant dates it falls back on
# the previous method to fetch the most recent bucket
wdpa_from_constants = available_wdpa_databases.find {|object| object.key.include?("#{WDPA_UPDATE_MONTH.first(3)}#{WDPA_UPDATE_YEAR}") }
wdpa_from_constants ? wdpa_from_constants.object : latest_wdpa
end

def latest_wdpa
latest = available_wdpa_databases.max_by do |object|
filename = object.key # e.g. "WDPA_WDOECM_Sep2020_Public.gdb.zip"

Expand All @@ -56,9 +47,7 @@ def latest_wdpa
end

def available_wdpa_databases
@_available_wdpa_databases ||= begin
bucket_name = Rails.application.secrets.aws_bucket
@s3.bucket(bucket_name).objects
end
bucket_name = Rails.application.secrets.aws_bucket
@s3.bucket(bucket_name).objects
end
end

0 comments on commit a6011f9

Please sign in to comment.