<commit_before>class Scrape
  class Persistance
    cattr_accessor :logger
    self.logger = Logger.new("#{Rails.root}/log/scrape.log")

    class << self
      def process(id, type)
        record =  if type == :heading
                    Heading.find(id)
                  else
                    Commodity.find(id)
                  end

        [true, false].each do |record_type|
          begin
            s = Scrape.new(scrape_id: record.code.first(10),
                           heading: record.is_a?(Heading),
                           export: record_type)
            tables = s.process_tables

            # process conditions
            if tables['footnotes'].present?
              process_footnotes(tables["footnotes"])
              process_measures(record, tables, 'third_country', record_type)
              process_measures(record, tables, 'specific_countries', record_type, true)
            end
          rescue Exception => e
            logger.error "Error: #{record.class.name} #{record.id} #{record.code} #{e}"
          end
        end
      end<commit_msg>Prefer cradle-to-grave naming<commit_after>class Scrape
  class Persistance
    cattr_accessor :logger
    self.logger = Logger.new("#{Rails.root}/log/scrape.log")

    class << self
      def process(id, type)
        record =  if type == :heading
                    Heading.find(id)
                  else
                    Commodity.find(id)
                  end

        [true, false].each do |export|
          begin
            s = Scrape.new(scrape_id: record.code.first(10),
                           heading: record.is_a?(Heading),
                           export: export)
            tables = s.process_tables

            # process conditions
            if tables['footnotes'].present?
              process_footnotes(tables["footnotes"])
              process_measures(record, tables, 'third_country', export)
              process_measures(record, tables, 'specific_countries', export, true)
            end
          rescue Exception => e
            logger.error "Error: #{record.class.name} #{record.id} #{record.code} #{e}"
          end
        end
      end
{'fraction_non_alphanumeric': 0.1003683241252302, 'fraction_numerical': 0.001841620626151013, 'mean_word_length': 1.5899880810488678, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7188625', 'n_tokens_mistral': 596, 'n_tokens_neox': 568, 'n_words': 125}