mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
fix n+1 on mailing job (#673)
This commit is contained in:
@@ -14,8 +14,14 @@ class CheckStreakPhysicalMailJob < ApplicationJob
|
|||||||
|
|
||||||
over_7_day_streaks = streaks.select { |_, streak| streak > 7 }.keys
|
over_7_day_streaks = streaks.select { |_, streak| streak > 7 }.keys
|
||||||
|
|
||||||
|
existing_user_ids = PhysicalMail.going_out
|
||||||
|
.where(mission_type: :first_time_7_streak)
|
||||||
|
.where(user_id: over_7_day_streaks)
|
||||||
|
.pluck(:user_id)
|
||||||
|
.to_set
|
||||||
|
|
||||||
over_7_day_streaks.each do |user_id|
|
over_7_day_streaks.each do |user_id|
|
||||||
next if PhysicalMail.going_out.exists?(user_id: user_id, mission_type: :first_time_7_streak)
|
next if existing_user_ids.include?(user_id)
|
||||||
|
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user