<commit_before>TahiNotifier.subscribe("author:created") do |subscription_name, payload|
  klass      = payload[:klass]
  id         = payload[:id]

  # generic Authors may have been created in a different task, so
  # convert them to PlosAuthors
  paper = klass.find(id).paper
  paper.tasks_for_type("PlosAuthors::PlosAuthorsTask").each do |task|
    task.convert_generic_authors!
  end
end

TahiNotifier.subscribe("plos_authors/plos_author:created", "plos_authors/plos_author:updated") do |subscription_name, payload|
  action     = payload[:action]
  klass      = payload[:klass]
  id         = payload[:id]

  EventStream.new(action, klass, id, subscription_name).post
end

TahiNotifier.subscribe("plos_authors/plos_author:destroyed") do |subscription_name, payload|
  id         = payload[:id]
  paper_id   = payload[:paper_id]

  EventStream.post_event(
    Paper,
    paper_id,
    { action: "destroyed", plos_authors: [id], subscription_name: subscription_name }.to_json
  )
end<commit_msg>Add event streaming for plos_authors destroy<commit_after>TahiNotifier.subscribe("author:created") do |subscription_name, payload|
  klass      = payload[:klass]
  id         = payload[:id]

  # generic Authors may have been created in a different task, so
  # convert them to PlosAuthors
  paper = klass.find(id).paper
  paper.tasks_for_type("PlosAuthors::PlosAuthorsTask").each do |task|
    task.convert_generic_authors!
  end
end

TahiNotifier.subscribe("plos_authors/plos_author:created", "plos_authors/plos_author:updated") do |subscription_name, payload|
  action     = payload[:action]
  klass      = payload[:klass]
  id         = payload[:id]

  EventStream.new(action, klass, id, subscription_name).post
end

TahiNotifier.subscribe("plos_authors/plos_author:destroyed") do |subscription_name, payload|
  action     = payload[:action]
  klass      = payload[:klass]
  id         = payload[:id]

  EventStream.new(action, klass, id, subscription_name).destroy
end
{'fraction_non_alphanumeric': 0.10766886744540376, 'fraction_numerical': 0.0, 'mean_word_length': 4.441988950276243, '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': '530617', 'n_tokens_mistral': 635, 'n_tokens_neox': 627, 'n_words': 132}