<commit_before>module GobiertoBudgets
  class BudgetLineExportPresenter < BudgetLinePresenter

    INDEX_KEYS = { GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_forecast => :value_budget_initial,
                   GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_forecast_updated => :value_budget_modified,
                   GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_executed => :value_budget_execution }

    def initialize(attributes)
      super
      @attributes[:index_values] = Hash[INDEX_KEYS.values.product([nil])].tap do |attrs|
        attrs[INDEX_KEYS[@attributes[:index]]] = @attributes[:amount] if @attributes[:index].present?
      end
    end

    def self.csv_columns
      %w(year code area kind name description initial_value modified_value executed_value organization_id functional_code custom_code ID parent_code level updated_atorganization_id)
    end

    def index_values
      @attributes[:index_values]
    end

    def merge!(budget_line)
      if id == budget_line.id
        index_values.merge!(budget_line.index_values) { |index, old, new| new.present? ? new : old }
      end
    end

    def updated_at
      @updated_at ||=
        begin
          @attributes[:updated_at] ||
            SiteStats.new(site: @attributes[:site], year: @attributes[:year]).budgets_data_updated_at ||
            Date.new(@attributes[:year])
        end
    end

    def index
      @attributes[:index]
    end

    def organization_id
      @attributes[:site].organization_id<commit_msg>Fix column name<commit_after>module GobiertoBudgets
  class BudgetLineExportPresenter < BudgetLinePresenter

    INDEX_KEYS = { GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_forecast => :value_budget_initial,
                   GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_forecast_updated => :value_budget_modified,
                   GobiertoBudgets::SearchEngineConfiguration::BudgetLine.index_executed => :value_budget_execution }

    def initialize(attributes)
      super
      @attributes[:index_values] = Hash[INDEX_KEYS.values.product([nil])].tap do |attrs|
        attrs[INDEX_KEYS[@attributes[:index]]] = @attributes[:amount] if @attributes[:index].present?
      end
    end

    def self.csv_columns
      %w(year code area kind name description initial_value modified_value executed_value organization_id functional_code custom_code ID parent_code level updated_at)
    end

    def index_values
      @attributes[:index_values]
    end

    def merge!(budget_line)
      if id == budget_line.id
        index_values.merge!(budget_line.index_values) { |index, old, new| new.present? ? new : old }
      end
    end

    def updated_at
      @updated_at ||= begin
        @attributes[:updated_at] ||
          SiteStats.new(site: @attributes[:site], year: @attributes[:year]).budgets_data_updated_at ||
          Date.new(@attributes[:year])
      end
    end

    def index
      @attributes[:index]
    end

    def organization_id
      @attributes[:site].organization_id
{'fraction_non_alphanumeric': 0.09259863058363221, 'fraction_numerical': 0.0, 'mean_word_length': 3.5586924219910845, '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': '5324555', 'n_tokens_mistral': 901, 'n_tokens_neox': 854, 'n_words': 163}