<commit_before>namespace :rates do
  task setup: :environment do
    require 'currency'
    require 'fixer'
  end

  desc 'Load all rates'
  task load: :setup do
    Currency.dataset.delete
    data = Fixer::Feed.new(:historical)
    Currency.multi_insert(data.to_a)
  end

  desc 'Update rates'
  task update: :setup do
    Fixer::Feed.new.each do |hsh|
      Currency.find_or_create(hsh)
    end
  end
end<commit_msg>Wrap bulk insert in a transaction<commit_after>namespace :rates do
  task setup: :environment do
    require 'currency'
    require 'fixer'
  end

  desc 'Load all rates'
  task load: :setup do
    Currency.db.transaction do
      Currency.dataset.delete
      data = Fixer::Feed.new(:historical)
      Currency.multi_insert(data.to_a)
    end
  end

  desc 'Update rates'
  task update: :setup do
    Fixer::Feed.new.each do |hsh|
      Currency.find_or_create(hsh)
    end
  end
end
{'fraction_non_alphanumeric': 0.09080841638981174, 'fraction_numerical': 0.0, 'mean_word_length': 3.0538116591928253, 'pattern_counts': {'":': 0, '<': 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': '5070026', 'n_tokens_mistral': 314, 'n_tokens_neox': 305, 'n_words': 85}