```ruby
# 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
```

Fix N+1 queries on campaign alerts
user
```ruby
# 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
```
assistant