<commit_before>class AddStateToCases < ActiveRecord::Migration[5.0]
  def up
    add_column :cases, :current_state, :string
    add_column :cases, :last_transitioned_at, :datetime

    Case.all.each do |kase|
      transition = kase.transitions.order(:sort_key).last
      if transition.nil?
        kase.update!(current_state: 'unassigned', last_transitioned_at: kase.created_at)
      else
        transition.record_state_change(kase) unless transition.nil?
      end
      puts "Updated Case Id #{kase.id} with state #{kase.current_state}"<commit_msg>Fix migration so that db can be reseeded<commit_after>class AddStateToCases < ActiveRecord::Migration[5.0]
  def up
    add_column :cases, :current_state, :string
    add_column :cases, :last_transitioned_at, :datetime

    Case.unscoped.all.each do |kase|
      transition = kase.transitions.order(:sort_key).last
      if transition.nil?
        kase.update!(current_state: 'unassigned', last_transitioned_at: kase.created_at)
      else
        transition.record_state_change(kase) unless transition.nil?
      end
      puts "Updated Case Id #{kase.id} with state #{kase.current_state}"
{'fraction_non_alphanumeric': 0.10052447552447552, 'fraction_numerical': 0.0034965034965034965, 'mean_word_length': 3.9141630901287554, 'pattern_counts': {'":': 0, '<': 5, '<?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': '817595', 'n_tokens_mistral': 364, 'n_tokens_neox': 364, 'n_words': 80}