<commit_before># frozen_string_literal: true

json.alerts @campaign.public_alerts do |alert|
  json.id alert.id
  json.type alert.type
  json.created_at alert.created_at
  json.user alert.user&.username
  json.course alert.course.title
  json.course_slug alert.course.slug
  json.article alert.article&.title
  json.article_url alert.article&.url
end
<commit_msg>Fix N+1 queries on campaign alerts<commit_after># frozen_string_literal: true

json.alerts @campaign.public_alerts.includes(:course, :user, article: :wiki) do |alert|
  json.id alert.id
  json.type alert.type
  json.created_at alert.created_at
  json.user alert.user&.username
  json.course alert.course.title
  json.course_slug alert.course.slug
  json.article alert.article&.title
  json.article_url alert.article&.url
end

{'fraction_non_alphanumeric': 0.09898477157360407, 'fraction_numerical': 0.0012690355329949238, 'mean_word_length': 4.717391304347826, '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': '7307048', 'n_tokens_mistral': 266, 'n_tokens_neox': 266, 'n_words': 56}