Fix n+1 on currently_hacking email list (#319)

This commit is contained in:
Max Wofford
2025-06-16 14:29:53 -04:00
committed by GitHub
parent 4bdb8b7169
commit 84e92cc844

View File

@@ -15,7 +15,7 @@ class Cache::CurrentlyHackingJob < Cache::ActivityJob
.where("time > ?", 5.minutes.ago.to_f)
.select("DISTINCT ON (user_id) user_id, project, time, users.*")
.order("user_id, time DESC")
.includes(user: :project_repo_mappings)
.includes(user: [ :project_repo_mappings, :email_addresses ])
.index_by(&:user_id)
users = recent_heartbeats.values.map(&:user)