<commit_before># frozen_string_literal: true

class PersonObserver < ActiveRecord::Observer
  def after_destroy(person)
    Result.where(person_id: person.id).update_all(
      person_id: nil,
      name: nil,
      first_name: nil,
      last_name: nil
    )
    true
  end

  def around_update(person)
    if person.first_name_changed? || person.last_name_changed?
      yield
      person.results.each do |result|
        result.cache_attributes! :non_event if result[:name] != person.name(result.year)
      end
    end
    true
  end
end<commit_msg>Use around_update to hold reference to previous person<commit_after># frozen_string_literal: true

class PersonObserver < ActiveRecord::Observer
  def after_destroy(person)
    Result.where(person_id: person.id).update_all(
      person_id: nil,
      name: nil,
      first_name: nil,
      last_name: nil
    )
    true
  end

  def around_update(person)
    yield

    if person.first_name_changed? || person.last_name_changed?
      person.results.each do |result|
        result.cache_attributes! :non_event if result[:name] != person.name(result.year)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08604038630377524, 'fraction_numerical': 0.0, 'mean_word_length': 3.1605839416058394, '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': '511633', 'n_tokens_mistral': 358, 'n_tokens_neox': 354, 'n_words': 83}