<commit_before>module GobiertoBudgets
  module ApplicationHelper

    def current_parameters_with_year(year)
      params.except(:host, :port, :protocol).merge(year: year).permit!
    end

    def sign(v1, v2 = nil)
      return 'sign-neutral' if v1.blank? || v2.blank?
      diff = v1 - v2
      if diff > 0
        'sign-up'
      elsif diff < 0
        'sign-down'
      else
        'sign-neutral'
      end
    rescue
      'sign-neutral'
    end

    def format_currency(n, absolute_value = false)
      return nil if n.blank?
      n = n.abs if absolute_value

      if n.abs > 1_000_000
        "#{helpers.number_with_precision(n.to_f / 1_000_000.to_f, precision: 1, strip_insignificant_zeros: true)}M€"
      else
        helpers.number_to_currency(n, precision: 1, strip_insignificant_zeros: true)
      end
    end

    def delta_percentage(current_year_value, old_value, sign = nil)
      value = ((current_year_value.to_f - old_value.to_f)/old_value.to_f) * 100
      formatted_value = number_with_precision(value, precision: 2).to_s + "%"
      if sign
        "#{value > 0 ? '+ ' : ''} #{formatted_value}"
      else
        formatted_value
      end
    end

    def percentage_of_total(value, total)
      number_with_precision((value.to_f / total.to_f) * 100, precision: 2) + '%'
    end

    def budget_line_denomination(area_name, code, kind, capped = -1)<commit_msg>Big numbers separation<commit_after>module GobiertoBudgets
  module ApplicationHelper

    def current_parameters_with_year(year)
      params.except(:host, :port, :protocol).merge(year: year).permit!
    end

    def sign(v1, v2 = nil)
      return 'sign-neutral' if v1.blank? || v2.blank?
      diff = v1 - v2
      if diff > 0
        'sign-up'
      elsif diff < 0
        'sign-down'
      else
        'sign-neutral'
      end
    rescue
      'sign-neutral'
    end

    def format_currency(n, absolute_value = false)
      return nil if n.blank?
      n = n.abs if absolute_value

      if n.abs > 1_000_000
        "#{helpers.number_with_precision(n.to_f / 1_000_000.to_f, precision: 1, strip_insignificant_zeros: true)} M€"
      else
        helpers.number_to_currency(n, precision: 1, strip_insignificant_zeros: true)
      end
    end

    def delta_percentage(current_year_value, old_value, sign = nil)
      value = ((current_year_value.to_f - old_value.to_f)/old_value.to_f) * 100
      formatted_value = number_with_precision(value, precision: 2).to_s + "%"
      if sign
        "#{value > 0 ? '+ ' : ''} #{formatted_value}"
      else
        formatted_value
      end
    end

    def percentage_of_total(value, total)
      number_with_precision((value.to_f / total.to_f) * 100, precision: 2) + '%'
    end

    def budget_line_denomination(area_name, code, kind, capped = -1)
{'fraction_non_alphanumeric': 0.10560344827586207, 'fraction_numerical': 0.02442528735632184, 'mean_word_length': 2.588917525773196, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '409080', 'n_tokens_mistral': 1027, 'n_tokens_neox': 949, 'n_words': 208}