From 91e2e6d5c0e594c440e8d374a78dc2f3f8d5cac7 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Jun 2022 14:17:21 +0100 Subject: [PATCH 01/15] feat: added a download link for global statistics --- app/controllers/global_statistics_controller.rb | 14 ++++++++++++++ app/views/home/index.html.erb | 1 + config/routes.rb | 2 ++ lib/modules/wdpa/global_stats_importer.rb | 5 ++++- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/controllers/global_statistics_controller.rb diff --git a/app/controllers/global_statistics_controller.rb b/app/controllers/global_statistics_controller.rb new file mode 100644 index 000000000..0ad219340 --- /dev/null +++ b/app/controllers/global_statistics_controller.rb @@ -0,0 +1,14 @@ +class GlobalStatisticsController < ApplicationController + def show + send_file filename, type: 'text/csv', disposition: 'attachment' + end + + private + + def filename + directory = "#{Rails.root}/lib/data/seeds/" + global_statistics_csvs = Dir.glob("#{directory}/global_statistics*") + latest_global_statistics_file = global_statistics_csvs.sort.last + latest_global_statistics_file + end +end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 1b058dc58..9a50283af 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -8,6 +8,7 @@
<%= render partial: "partials/cards/facts", locals: { cards: @site_facts } %>

Statistics updated: <%= @update_date %>

+ <%= link_to('Download latest global statistics', global_statistics_path) %>
<%= render partial: "partials/search/protected-areas", locals: { config: @config_search_areas } %> diff --git a/config/routes.rb b/config/routes.rb index 5ed45e8c8..1bc08d342 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,8 @@ get '/country/:iso/compare(/:iso_to_compare)', to: 'country#compare', as: 'compare_countries' get '/country/:iso/protected_areas', to: 'country#protected_areas', as: 'country_protected_areas' + get '/global_statistics', to: 'global_statistics#show' + # JSON endpoints get '/downloads/poll', to: 'downloads#poll', as: 'download_poll' resources :downloads, only: [:show, :create, :update] diff --git a/lib/modules/wdpa/global_stats_importer.rb b/lib/modules/wdpa/global_stats_importer.rb index 1ba093e71..07fff3fc0 100644 --- a/lib/modules/wdpa/global_stats_importer.rb +++ b/lib/modules/wdpa/global_stats_importer.rb @@ -10,7 +10,10 @@ def self.import CSV.foreach(latest_global_statistics_csv, headers: true) do |row| field = row['type'] value = parse_value(row['value']) - attrs.merge!("#{field}": value) + + # The global_statistics csv can now be downloaded so a methodology url has been added + # to the end of the spreadsheet. We need to not add this line to the attributes. + attrs.merge!("#{field}": value) if field.present? end stats = GlobalStatistic.first_or_initialize(attrs) From a1c39914dde7ca4861568773c4ca86cd8c88838a Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 6 Jun 2022 16:45:08 +0100 Subject: [PATCH 02/15] fix: trying to add verifier to download attributes --- lib/modules/download/queries.rb | 2 +- lib/modules/ogr/postgres.rb | 2 +- lib/modules/wdpa/data_standard/source.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/modules/download/queries.rb b/lib/modules/download/queries.rb index 113ce3c07..43eb00f8e 100644 --- a/lib/modules/download/queries.rb +++ b/lib/modules/download/queries.rb @@ -18,7 +18,7 @@ module Queries SOURCE_COLUMNS = [ :metadataid, :data_title, :resp_party, - :year, :update_yr, :char_set, + :year, :update_yr, :char_set, :verifier, :ref_system, :scale, :lineage, :citation, :disclaimer, :language ] diff --git a/lib/modules/ogr/postgres.rb b/lib/modules/ogr/postgres.rb index 108b29e6b..9e2493adb 100644 --- a/lib/modules/ogr/postgres.rb +++ b/lib/modules/ogr/postgres.rb @@ -5,7 +5,7 @@ class ExportError < StandardError; end; DRIVERS = { shapefile: 'ESRI Shapefile', csv: 'CSV', - gdb: 'FileGDB' + gdb: 'OpenFileGDB' } TEMPLATE_DIRECTORY = File.join(File.dirname(__FILE__), 'command_templates') diff --git a/lib/modules/wdpa/data_standard/source.rb b/lib/modules/wdpa/data_standard/source.rb index decf0d42b..9d359f13f 100644 --- a/lib/modules/wdpa/data_standard/source.rb +++ b/lib/modules/wdpa/data_standard/source.rb @@ -12,6 +12,7 @@ class Wdpa::DataStandard::Source < Wdpa::DataStandard :lineage => {name: :lineage, type: :string}, :citation => {name: :citation, type: :string}, :disclaimer => {name: :disclaimer, type: :string}, - :language => {name: :language, type: :string} + :language => {name: :language, type: :string}, + :verifier => {name: :verifier, type: :string} } end From 0d89228a20101b5cae7297742221c5c9e9c754f4 Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 7 Jun 2022 13:53:20 +0100 Subject: [PATCH 03/15] fix: stop trying to load the_geom into memory, because some are huge and this stopped pages loading --- app/models/protected_area.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/protected_area.rb b/app/models/protected_area.rb index f5f3b833f..0fa783feb 100644 --- a/app/models/protected_area.rb +++ b/app/models/protected_area.rb @@ -254,7 +254,10 @@ def is_whs? private def is_point? - the_geom.geometry_type.type_name.match('Point').present? + @is_point ||= begin + extent = bounds + extent[0][0] == extent[1][0] && extent[0][1] == extent[1][1] + end end def bounding_box_query From 0bd8e2614c2acf1579cbc9844b96c0160966706a Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 7 Jun 2022 14:48:02 +0100 Subject: [PATCH 04/15] fix: typo --- app/views/partials/messages/_message-citation.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/partials/messages/_message-citation.html.erb b/app/views/partials/messages/_message-citation.html.erb index 917fef16b..f8a54720e 100644 --- a/app/views/partials/messages/_message-citation.html.erb +++ b/app/views/partials/messages/_message-citation.html.erb @@ -1,4 +1,4 @@

citation

-

UNEP-WCMC (<%= Date.today.year %>). Protected Area Profile for <%= title %> from the World Database of Protected Areas, <%= Date.today.strftime("%B %Y") %>. Available at: www.protectedplanet.net

+

UNEP-WCMC (<%= Date.today.year %>). Protected Area Profile for <%= title %> from the World Database on Protected Areas, <%= Date.today.strftime("%B %Y") %>. Available at: www.protectedplanet.net

\ No newline at end of file From 722326b873ea99d0d7601ca0887d12c74153993a Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 9 Jun 2022 10:25:11 +0100 Subject: [PATCH 05/15] feat: Removed key added in prrevious PR --- lib/modules/download/queries.rb | 5 +++-- lib/modules/wdpa/data_standard/source.rb | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/modules/download/queries.rb b/lib/modules/download/queries.rb index 43eb00f8e..3b89fa364 100644 --- a/lib/modules/download/queries.rb +++ b/lib/modules/download/queries.rb @@ -18,9 +18,10 @@ module Queries SOURCE_COLUMNS = [ :metadataid, :data_title, :resp_party, - :year, :update_yr, :char_set, :verifier, + :year, :update_yr, :char_set, :ref_system, :scale, :lineage, - :citation, :disclaimer, :language + :citation, :disclaimer, :language, + :verifier ] def self.for_points extra_columns={} diff --git a/lib/modules/wdpa/data_standard/source.rb b/lib/modules/wdpa/data_standard/source.rb index 9d359f13f..decf0d42b 100644 --- a/lib/modules/wdpa/data_standard/source.rb +++ b/lib/modules/wdpa/data_standard/source.rb @@ -12,7 +12,6 @@ class Wdpa::DataStandard::Source < Wdpa::DataStandard :lineage => {name: :lineage, type: :string}, :citation => {name: :citation, type: :string}, :disclaimer => {name: :disclaimer, type: :string}, - :language => {name: :language, type: :string}, - :verifier => {name: :verifier, type: :string} + :language => {name: :language, type: :string} } end From a40bb3690fd2d9b81c2c26baf27efa10879c88c8 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 9 Jun 2022 10:30:09 +0100 Subject: [PATCH 06/15] fix: Changed OpenFileGDB back to File GDB --- lib/modules/ogr/postgres.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/ogr/postgres.rb b/lib/modules/ogr/postgres.rb index 9e2493adb..108b29e6b 100644 --- a/lib/modules/ogr/postgres.rb +++ b/lib/modules/ogr/postgres.rb @@ -5,7 +5,7 @@ class ExportError < StandardError; end; DRIVERS = { shapefile: 'ESRI Shapefile', csv: 'CSV', - gdb: 'OpenFileGDB' + gdb: 'FileGDB' } TEMPLATE_DIRECTORY = File.join(File.dirname(__FILE__), 'command_templates') From 58f0c69363a2298ef13eafd6acfb335162893f76 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 9 Jun 2022 13:28:28 +0100 Subject: [PATCH 07/15] feat: added maxZoom: 10 to mapbox defaults, and overide in the protected area controller --- app/controllers/protected_areas_controller.rb | 3 ++- app/javascript/components/map/default-options.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/protected_areas_controller.rb b/app/controllers/protected_areas_controller.rb index 8d830f8b6..164cb66aa 100644 --- a/app/controllers/protected_areas_controller.rb +++ b/app/controllers/protected_areas_controller.rb @@ -43,7 +43,8 @@ def show @map_options = { map: { - boundsUrl: @protected_area.extent_url + boundsUrl: @protected_area.extent_url, + maxZoom: 0 } } diff --git a/app/javascript/components/map/default-options.js b/app/javascript/components/map/default-options.js index 39b131004..833f7332b 100644 --- a/app/javascript/components/map/default-options.js +++ b/app/javascript/components/map/default-options.js @@ -17,6 +17,7 @@ export const MAP_OPTIONS_DEFAULT = { attributionControl: false, preserveDrawingBuffer: true, // needed for PDF rendering zoom: 1.3, + maxZoom: 10 // Maximum zoom where tiles are cached for the web-map service //bounds: [[-180, -90], [180, 90]], //boundingISO: ISO3, //boundingRegion; Name e.g. Europe, From 459bec93f8cf089f4866fcf8afa7f004a8217a18 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 10 Jun 2022 11:36:56 +0100 Subject: [PATCH 08/15] feat: text updates - Protected Areas to Protected Areas and OECMs plus others --- app/serializers/search/areas_serializer.rb | 2 +- app/views/partials/cards/_squares.html.erb | 1 + config/locales/global/en.yml | 1 + config/locales/home/en.yml | 10 +++++----- config/locales/map/en.yml | 4 ++-- config/locales/search/en.yml | 2 +- config/locales/stats/en.yml | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/serializers/search/areas_serializer.rb b/app/serializers/search/areas_serializer.rb index c0a6864e3..2b65c9639 100644 --- a/app/serializers/search/areas_serializer.rb +++ b/app/serializers/search/areas_serializer.rb @@ -34,7 +34,7 @@ def sites def geo_hash(geo_type, areas, total=0) areas = areas.present? ? areas.first(9) : [] - geo_type_locale = geo_type == 'site' ? 'area-types.wdpa' : "geo-types.#{geo_type.pluralize}" + geo_type_locale = "geo-types.#{geo_type.pluralize}" { geoType: geo_type, title: I18n.t("global.#{geo_type_locale}"), diff --git a/app/views/partials/cards/_squares.html.erb b/app/views/partials/cards/_squares.html.erb index f4a09155d..216543dc3 100644 --- a/app/views/partials/cards/_squares.html.erb +++ b/app/views/partials/cards/_squares.html.erb @@ -9,6 +9,7 @@ class: 'card__link', style: "background-image: url('#{card[:image]}')" do %> + <%# @TODO: styling 269 %>

<%= card[:title] %>

<% end %> diff --git a/config/locales/global/en.yml b/config/locales/global/en.yml index 5ab55c60b..be9528f3e 100644 --- a/config/locales/global/en.yml +++ b/config/locales/global/en.yml @@ -20,6 +20,7 @@ en: geo-types: countries: Countries regions: Regions + sites: Protected Areas and OECMs logos: iucn: IUCN logo pp: Protected Planet logo diff --git a/config/locales/home/en.yml b/config/locales/home/en.yml index 020ca0069..0fe6cd389 100644 --- a/config/locales/home/en.yml +++ b/config/locales/home/en.yml @@ -3,13 +3,13 @@ en: facts: - theme: terrestrial - title: Terrestrial protected area coverage + title: Terrestrial and inland waters protected area coverage - theme: marine title: Marine protected area coverage - theme: oecm - title: Terrestrial protected area & OECM coverage + title: Terrestrial and inland waters protected area & OECM coverage - theme: oecm title: Marine protected area & OECM coverage @@ -34,14 +34,14 @@ en: icon: area categories: - - title: Marine Protected Areas + title: Marine Protected Areas and OECMs slug: /marine-protected-areas filter: 'marine' - - title: Terrestrial Protected Areas + title: Terrestrial and Inland Waters Protected Areas and OECMs slug: filter: 'terrestrial' - - title: Green Listed Protected Areas + title: Green Listed Protected Areas and OECMs slug: /green-list filter: 'is_green_list' diff --git a/config/locales/map/en.yml b/config/locales/map/en.yml index 2e699f3b3..e95cb9b88 100644 --- a/config/locales/map/en.yml +++ b/config/locales/map/en.yml @@ -6,14 +6,14 @@ en: greenlist_marine: title: Marine Green Listed Protected Areas terrestrial_wdpa: - title: Terrestrial Protected Areas + title: Terrestrial and Inland Waters Protected Areas marine_wdpa: title: Marine Protected Areas oecm_marine: title: Other effective area-based conservation measures oecm: title: Other effective area-based conservation measures - title: Discover Protected Areas + title: Discover Protected Areas and OECMs title_oecm: Discover OECMs disclaimer: heading: Map Disclaimer diff --git a/config/locales/search/en.yml b/config/locales/search/en.yml index a41e067e9..a8b6df2bd 100644 --- a/config/locales/search/en.yml +++ b/config/locales/search/en.yml @@ -40,7 +40,7 @@ en: filter-group-type: title: Type options: - terrestrial: Terrestrial + terrestrial: Terrestrial and inland waters marine: Marine geo-types: region: Regions diff --git a/config/locales/stats/en.yml b/config/locales/stats/en.yml index 5a5556757..9106b1470 100644 --- a/config/locales/stats/en.yml +++ b/config/locales/stats/en.yml @@ -13,8 +13,8 @@ en: total: Total marine and coastal area coverage_terrestrial: covered: Land area covered - title_wdpa: Terrestrial protected area coverage - title_wdpa_oecm: Terrestrial protected area & OECM coverage + title_wdpa: Terrestrial and inland waters protected area coverage + title_wdpa_oecm: Terrestrial and inland waters protected area & OECM coverage total: Total land area coverage-chart-smallprint: The graph excludes status years with no information reported (STATUS_YR = 0). countries: Number of countries From f546dc322d8cfe958936c5a9f4bb92f26d2586de Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 10 Jun 2022 11:52:33 +0100 Subject: [PATCH 09/15] feat: Styled the titles in the squares --- .../stylesheets/components/cards/cards/_cards-squares.scss | 5 +++++ app/views/partials/cards/_squares.html.erb | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/components/cards/cards/_cards-squares.scss b/app/assets/stylesheets/components/cards/cards/_cards-squares.scss index 3bc232a33..3e5fabfdb 100644 --- a/app/assets/stylesheets/components/cards/cards/_cards-squares.scss +++ b/app/assets/stylesheets/components/cards/cards/_cards-squares.scss @@ -60,5 +60,10 @@ $cards-squares-width-tablet: 48%; &:before { @include border-radius; } } + + &__title { + overflow-wrap: break-word; + text-align: center; + } } } \ No newline at end of file diff --git a/app/views/partials/cards/_squares.html.erb b/app/views/partials/cards/_squares.html.erb index 216543dc3..f4a09155d 100644 --- a/app/views/partials/cards/_squares.html.erb +++ b/app/views/partials/cards/_squares.html.erb @@ -9,7 +9,6 @@ class: 'card__link', style: "background-image: url('#{card[:image]}')" do %> - <%# @TODO: styling 269 %>

<%= card[:title] %>

<% end %> From 2672bbe7c4edd20e344f3a733b11a2e03f50af87 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 10 Jun 2022 12:53:41 +0100 Subject: [PATCH 10/15] feat: Use latest PAME data csv for date of generated download csv --- app/controllers/pame_controller.rb | 6 ++---- app/models/pame_evaluation.rb | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/pame_controller.rb b/app/controllers/pame_controller.rb index f2fa7ff90..3358f21e8 100644 --- a/app/controllers/pame_controller.rb +++ b/app/controllers/pame_controller.rb @@ -7,9 +7,6 @@ class PameController < ApplicationController filters: [] }.to_json - # Format for this date is: Year-MON (4 digits-3 chars) - UPDATED_AT = "2020-DEC".freeze - def index @table_attributes = PameEvaluation::TABLE_ATTRIBUTES.to_json @filters = PameEvaluation.filters_to_json @@ -26,10 +23,11 @@ def list end def download + last_update = PameEvaluation.last_csv_update_date.strftime('%Y-%^b') send_data PameEvaluation.to_csv(params.to_json), { type: "text/csv; charset=utf-8; header=present", disposition: "attachment", - filename: "protectedplanet-pame-#{UPDATED_AT}.csv" } + filename: "protectedplanet-pame-#{last_update}.csv" } end end diff --git a/app/models/pame_evaluation.rb b/app/models/pame_evaluation.rb index c7399de5e..988f8d418 100644 --- a/app/models/pame_evaluation.rb +++ b/app/models/pame_evaluation.rb @@ -336,6 +336,12 @@ def self.to_csv(json = nil) generate_csv(where_statement, restricted_where_statement) end + + def self.last_csv_update_date + pame_data_csvs = Dir.glob("#{Rails.root}/lib/data/seeds/pame_data*") + latest_pame_csv = pame_data_csvs.sort.last.split('_').last + latest_pame_csv.split.first.to_date + end end From d5b99ca3fc60c940ed37ee42a85452fb514ed1c3 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 10 Jun 2022 12:59:29 +0100 Subject: [PATCH 11/15] feat: Moved latest file method to GlobalStatistic class --- app/controllers/global_statistics_controller.rb | 11 +---------- app/models/global_statistic.rb | 5 +++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/global_statistics_controller.rb b/app/controllers/global_statistics_controller.rb index 0ad219340..9fff06c6f 100644 --- a/app/controllers/global_statistics_controller.rb +++ b/app/controllers/global_statistics_controller.rb @@ -1,14 +1,5 @@ class GlobalStatisticsController < ApplicationController def show - send_file filename, type: 'text/csv', disposition: 'attachment' - end - - private - - def filename - directory = "#{Rails.root}/lib/data/seeds/" - global_statistics_csvs = Dir.glob("#{directory}/global_statistics*") - latest_global_statistics_file = global_statistics_csvs.sort.last - latest_global_statistics_file + send_file GlobalStatistic.latest_csv, type: 'text/csv', disposition: 'attachment' end end diff --git a/app/models/global_statistic.rb b/app/models/global_statistic.rb index a39045e8d..4922cbef4 100644 --- a/app/models/global_statistic.rb +++ b/app/models/global_statistic.rb @@ -39,4 +39,9 @@ def self.green_list_stats self.instance.send(column_name) end end + + def self.latest_csv + global_statistics_csvs = Dir.glob("#{Rails.root}/lib/data/seeds/global_statistics*") + global_statistics_csvs.sort.last + end end \ No newline at end of file From ae44bfa4047732866530e880b523be0cd3cb39df Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 10 Jun 2022 14:42:28 +0100 Subject: [PATCH 12/15] fix: give correct link for regions in filter results --- app/serializers/search/base_serializer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/serializers/search/base_serializer.rb b/app/serializers/search/base_serializer.rb index 5560a1112..9901355ea 100644 --- a/app/serializers/search/base_serializer.rb +++ b/app/serializers/search/base_serializer.rb @@ -39,6 +39,8 @@ def url(obj) protected_area_path(obj.wdpa_id) elsif obj.is_a?(Country) country_path(iso: obj.iso_3) + elsif obj.is_a?(Region) + region_path(iso: obj.iso) else '#' end From b1a9d8d423ec9488c26a648f4528ee1240446285 Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 15 Jun 2022 09:25:37 +0100 Subject: [PATCH 13/15] feat: renamed route to #download instead of #show --- app/controllers/global_statistics_controller.rb | 2 +- app/views/home/index.html.erb | 2 +- config/routes.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/global_statistics_controller.rb b/app/controllers/global_statistics_controller.rb index 9fff06c6f..f065b2594 100644 --- a/app/controllers/global_statistics_controller.rb +++ b/app/controllers/global_statistics_controller.rb @@ -1,5 +1,5 @@ class GlobalStatisticsController < ApplicationController - def show + def download send_file GlobalStatistic.latest_csv, type: 'text/csv', disposition: 'attachment' end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 9a50283af..fc08755db 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -8,7 +8,7 @@
<%= render partial: "partials/cards/facts", locals: { cards: @site_facts } %>

Statistics updated: <%= @update_date %>

- <%= link_to('Download latest global statistics', global_statistics_path) %> + <%= link_to('Download latest global statistics', global_statistics_download_path) %>
<%= render partial: "partials/search/protected-areas", locals: { config: @config_search_areas } %> diff --git a/config/routes.rb b/config/routes.rb index 1bc08d342..693959fac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,7 +34,7 @@ get '/country/:iso/compare(/:iso_to_compare)', to: 'country#compare', as: 'compare_countries' get '/country/:iso/protected_areas', to: 'country#protected_areas', as: 'country_protected_areas' - get '/global_statistics', to: 'global_statistics#show' + get '/global_statistics_download', to: 'global_statistics#download' # JSON endpoints get '/downloads/poll', to: 'downloads#poll', as: 'download_poll' From 69283b459313a7a03cffef2b953515b60381800a Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 16 Jun 2022 09:08:49 +0100 Subject: [PATCH 14/15] fix: specified a split pattern to split filename correctly --- app/models/pame_evaluation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/pame_evaluation.rb b/app/models/pame_evaluation.rb index 988f8d418..46d3fcb78 100644 --- a/app/models/pame_evaluation.rb +++ b/app/models/pame_evaluation.rb @@ -340,7 +340,7 @@ def self.to_csv(json = nil) def self.last_csv_update_date pame_data_csvs = Dir.glob("#{Rails.root}/lib/data/seeds/pame_data*") latest_pame_csv = pame_data_csvs.sort.last.split('_').last - latest_pame_csv.split.first.to_date + latest_pame_csv.split('.').first.to_date end end From c162e38879270add39a5d46dc13b393a8e404cd6 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 16 Jun 2022 09:46:10 +0100 Subject: [PATCH 15/15] fix/Changed urls so they work after recent API changes --- app/helpers/map_helper.rb | 2 +- app/models/protected_area.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/map_helper.rb b/app/helpers/map_helper.rb index 693e673bc..c1c3215eb 100644 --- a/app/helpers/map_helper.rb +++ b/app/helpers/map_helper.rb @@ -104,7 +104,7 @@ def all_services_for_point_query def country_extent_url (iso3) { - url: "https://data-gis.unep-wcmc.org/server/rest/services/GADM_EEZ_Layer/FeatureServer/0/query?where=iso_ter+%3D+%27#{iso3}%27&returnGeometry=false&returnExtentOnly=true&outSR=4326&f=pjson", + url: "https://data-gis.unep-wcmc.org/server/rest/services/GADM_EEZ_Layer/FeatureServer/0/query?where=iso_ter+%3D+#{iso3}&returnGeometry=false&returnExtentOnly=true&outSR=4326&f=pjson", padding: 5 } end diff --git a/app/models/protected_area.rb b/app/models/protected_area.rb index 0fa783feb..3cb2b717b 100644 --- a/app/models/protected_area.rb +++ b/app/models/protected_area.rb @@ -237,12 +237,12 @@ def arcgis_layer end def arcgis_query_string - "/query?where=wdpaid+%3D+%27#{wdpa_id}%27&geometryType=esriGeometryEnvelope&returnGeometry=true&f=geojson" + "/query?where=wdpaid+%3D+#{wdpa_id}&geometryType=esriGeometryEnvelope&returnGeometry=true&f=geojson" end def extent_url { - url: "#{arcgis_layer}/query?where=wdpaid+%3D+%27#{wdpa_id}%27&returnGeometry=false&returnExtentOnly=true&outSR=4326&f=pjson", + url: "#{arcgis_layer}/query?where=wdpaid+%3D+#{wdpa_id}&returnGeometry=false&returnExtentOnly=true&outSR=4326&f=pjson", padding: 0.2 } end