Skip to content

Commit

Permalink
Chore: Hide IOT country
Browse files Browse the repository at this point in the history
  • Loading branch information
IMDaniyal committed Jul 18, 2024
1 parent 22db2a8 commit 1491ec6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Country < ApplicationRecord

has_and_belongs_to_many :pame_evaluations

BLACKLISTED_ISO3 = ['IOT'].freeze #Add countries in this list which we dont to show anywhere

default_scope { where.not(iso_3: BLACKLISTED_ISO3) }

def wdpa_ids
protected_areas.map(&:wdpa_id)
end
Expand Down Expand Up @@ -97,11 +101,11 @@ def random_protected_areas wanted=1

def sources_per_country(exclude_oecms: false)
sources = ActiveRecord::Base.connection.execute("""
SELECT sources.title, EXTRACT(YEAR FROM sources.update_year) AS year, sources.responsible_party
SELECT sources.title, EXTRACT(YEAR FROM sources.update_year) AS year, sources.responsible_party
FROM sources
INNER JOIN countries_protected_areas
ON countries_protected_areas.country_id = #{self.id}
INNER JOIN protected_areas_sources
INNER JOIN protected_areas_sources
ON protected_areas_sources.protected_area_id = countries_protected_areas.protected_area_id
AND protected_areas_sources.source_id = sources.id
Expand Down Expand Up @@ -214,7 +218,7 @@ def coverage_growth(exclude_oecms)

def protected_areas_inner_join(group_by, exclude_oecms)
"""
SELECT #{group_by}, COUNT(protected_areas.id) AS count
SELECT #{group_by}, COUNT(protected_areas.id) AS count
FROM protected_areas
INNER JOIN countries_protected_areas
ON protected_areas.id = countries_protected_areas.protected_area_id
Expand Down

0 comments on commit 1491ec6

Please sign in to comment.