<commit_before>module OmertaLogger
  module Import
    class Hitlist < Base
      def set_target(hitlist, xml_hitlist)
        hitlist.target = @version.users.find_or_create_by(ext_user_id: xml_hitlist.css('target').first['id'].to_i,
                                                          name:        xml_hitlist.css('target').text)
      end

      def set_hitlister(hitlist, xml_hitlist)
        if xml_hitlist.css('by').first['id'].to_i != 0
          hitlist.hitlister = @version.users.find_or_create_by(ext_user_id: xml_hitlist.css('by').first['id'].to_i,
                                                               name:        xml_hitlist.css('by').text)
        else
          hitlist.hitlister = nil
        end
      end

      def import
        @xml.css('hitlists hitlist').each do |xml_hitlist|
          hitlist        = @version.hitlists.find_or_create_by(ext_hitlist_id: xml_hitlist['id'].to_i)
          hitlist.date   = Time.at(xml_hitlist.css('time').text.to_i)
          hitlist.amount = Time.at(xml_hitlist.css('amount').text.to_i)
          set_target(hitlist, xml_hitlist)
          set_hitlister(hitlist, xml_hitlist)

          hitlist.save
        end
      end
    end
  end<commit_msg>fix hitlist amount being converted to a date<commit_after>module OmertaLogger
  module Import
    class Hitlist < Base
      def set_target(hitlist, xml_hitlist)
        hitlist.target = @version.users.find_or_create_by(ext_user_id: xml_hitlist.css('target').first['id'].to_i,
                                                          name:        xml_hitlist.css('target').text)
      end

      def set_hitlister(hitlist, xml_hitlist)
        if xml_hitlist.css('by').first['id'].to_i != 0
          hitlist.hitlister = @version.users.find_or_create_by(ext_user_id: xml_hitlist.css('by').first['id'].to_i,
                                                               name:        xml_hitlist.css('by').text)
        else
          hitlist.hitlister = nil
        end
      end

      def import
        @xml.css('hitlists hitlist').each do |xml_hitlist|
          hitlist        = @version.hitlists.find_or_create_by(ext_hitlist_id: xml_hitlist['id'].to_i)
          hitlist.date   = Time.at(xml_hitlist.css('time').text.to_i)
          hitlist.amount = xml_hitlist.css('amount').text.to_i
          set_target(hitlist, xml_hitlist)
          set_hitlister(hitlist, xml_hitlist)

          hitlist.save
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.10519902518277822, 'fraction_numerical': 0.0008123476848090983, 'mean_word_length': 1.9079102715466352, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7641285', 'n_tokens_mistral': 772, 'n_tokens_neox': 761, 'n_words': 114}