<commit_before>namespace :build do
  namespace :migrate do
    task :pull_request_data do
      require 'travis'
      Travis::Database.connect

      Build.pull_requests.where('pull_request_number IS NULL OR pull_request_title IS NULL').
            includes(:request).find_in_batches do |builds|
        Build.transaction do
          builds.each do |build|
            attrs = {
              :pull_request_number => build.request.pull_request_number,
              :pull_request_title  => build.request.pull_request_title
            }

            Build.where(id: build.id).update_all(attrs)
          end
        end
      end
    end
  end
end<commit_msg>Fetch all builds in PR rake task, but skip when it's already filled in<commit_after>namespace :build do
  namespace :migrate do
    task :pull_request_data do
      require 'travis'
      Travis::Database.connect

      Build.pull_requests.includes(:request).order('id DESC').find_in_batches do |builds|
        Build.transaction do
          builds.each do |build|
            next if build.pull_request_number && build.pull_request_title
            attrs = {
              :pull_request_number => build.request.pull_request_number,
              :pull_request_title  => build.request.pull_request_title
            }

            Build.where(id: build.id).update_all(attrs)
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07614942528735633, 'fraction_numerical': 0.0, 'mean_word_length': 2.2170900692840645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '519362', 'n_tokens_mistral': 393, 'n_tokens_neox': 395, 'n_words': 90}