<commit_before>class MigrateFactRelationActivitiesWorker
  @queue = :aaa_migration

  def self.perform
    Activity.find(action: :added_supporting_evidence).each do |a|
      migrate_activity a, 'supporting'
    end

    Activity.find(action: :added_weakening_evidence).each do |a|
      migrate_activity a, 'weakening'
    end
  end

  def self.migrate_activity a, type
    fr = FactRelation.find(type: type, from_fact_id: a.subject.id,
      fact_id: a.object.id).first

    if fr
      a.subject = fr
      a.action = :created_fact_relation
      a.save!
    else
      a.delete
    end
  end
end<commit_msg>Delete invalid activities in migration<commit_after>class MigrateFactRelationActivitiesWorker
  @queue = :aaa_migration

  def self.perform
    Activity.find(action: :added_supporting_evidence).each do |a|
      migrate_activity a, 'supporting'
    end

    Activity.find(action: :added_weakening_evidence).each do |a|
      migrate_activity a, 'weakening'
    end
  end

  def self.migrate_activity a, type
    if a.still_valid?
      fr = FactRelation.find(type: type, from_fact_id: a.subject.id,
        fact_id: a.object.id).first

      if fr
        a.subject = fr
        a.action = :created_fact_relation
        a.save!
      else
        a.delete
      end
    else
      a.delete
    end
  end
end
{'fraction_non_alphanumeric': 0.08263836239575435, 'fraction_numerical': 0.0, 'mean_word_length': 2.7288135593220337, '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': '5524994', 'n_tokens_mistral': 456, 'n_tokens_neox': 442, 'n_words': 100}