<commit_before>class ThematicalAreasPresenter
  def initialize(cms_site)
    @cms_site = cms_site
  end

  def thematical_areas
    thematical_page = @cms_site.pages.find_by_slug('thematical-areas')
    ##TODO FERDI can you fill in this bit - not needed for ICCA registry
    ## Update variable in the view /partials/sub_partials/_themes.html.erb
    items = {
      "title": thematical_page.label,
      "cards": cards(thematical_page)
    }
  end

  private

  def cards(thematical_page)
    _cards = thematical_page.children.published
    _cards.map do |c|
      {
        obj: c,
        pas_no: pas_figure(c.label)
      }
    end
  end

  THEMATICAL_AREAS = {
    marine: 'Marine Protected Areas',
    green_list: 'The IUCN Green List of Protected and Conserved Areas',
    wdpa: 'WDPA',
    oecm: 'OECMs',
    connectivity: 'Connectivity Conservation',
    pame: 'Protected Areas Management Effectiveness (PAME)',
    equity: 'Equity and protected areas',
    aichi11: 'Global Partnership on Aichi Target 11'
  }.freeze
  def pas_figure(label)
    pas = ProtectedArea
    pas = case label
    when theme(:marine)
      pas.where(marine: true)
    when theme(:green_list)
      pas.where.not(green_list_status_id: nil)
    when theme(:wdpa)
      pas.wdpas
    when theme(:oecm)
      pas.oecms
    when theme(:pame)
      pas.with_pame_evaluations
    else
      -1 #Not applicable - hide ribbon
    end

    pas.respond_to?(:count) ? pas.count : pas
  end

  def theme(key)
    THEMATICAL_AREAS[key]
  end
end<commit_msg>added delimiters to numbers<commit_after>class ThematicalAreasPresenter
  include ActionView::Helpers::NumberHelper

  def initialize(cms_site)
    @cms_site = cms_site
  end

  def thematical_areas
    thematical_page = @cms_site.pages.find_by_slug('thematical-areas')
    ##TODO FERDI can you fill in this bit - not needed for ICCA registry
    ## Update variable in the view /partials/sub_partials/_themes.html.erb
    items = {
      "title": thematical_page.label,
      "cards": cards(thematical_page)
    }
  end

  private

  def cards(thematical_page)
    _cards = thematical_page.children.published
    _cards.map do |c|
      {
        obj: c,
        pas_no: pas_figure(c.label)
      }
    end
  end

  THEMATICAL_AREAS = {
    marine: 'Marine Protected Areas',
    green_list: 'The IUCN Green List of Protected and Conserved Areas',
    wdpa: 'WDPA',
    oecm: 'OECMs',
    connectivity: 'Connectivity Conservation',
    pame: 'Protected Areas Management Effectiveness (PAME)',
    equity: 'Equity and protected areas',
    aichi11: 'Global Partnership on Aichi Target 11'
  }.freeze
  def pas_figure(label)
    pas = ProtectedArea
    pas = case label
    when theme(:marine)
      pas.where(marine: true)
    when theme(:green_list)
      pas.where.not(green_list_status_id: nil)
    when theme(:wdpa)
      pas.wdpas
    when theme(:oecm)
      pas.oecms
    when theme(:pame)
      pas.with_pame_evaluations
    else
      -1 #Not applicable - hide ribbon
    end

    pas.respond_to?(:count) ? number_with_delimiter(pas.count) : pas
  end

  def theme(key)
    THEMATICAL_AREAS[key]
  end
end
{'fraction_non_alphanumeric': 0.08980891719745222, 'fraction_numerical': 0.0031847133757961785, 'mean_word_length': 2.960907944514502, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2969327', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1076, 'n_words': 266}