FIX: Respect pending_assign_reminder_threshold in enqueue_reminders (#572)

This commit is contained in:
Mark VanLandingham 2024-05-10 14:49:35 -05:00 committed by GitHub
parent e3c24ba2f2
commit 6978c752db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -22,6 +22,10 @@ module Jobs
Group.assign_allowed_groups.pluck(:id).join(",")
end
def reminder_threshold
@reminder_threshold ||= SiteSetting.pending_assign_reminder_threshold
end
def user_ids
global_frequency = SiteSetting.remind_assigns_frequency
frequency =
@ -54,7 +58,7 @@ module Jobs
AND assignments.assigned_to_type = 'User'
GROUP BY assignments.assigned_to_id
HAVING COUNT(assignments.assigned_to_id) > 1
HAVING COUNT(assignments.assigned_to_id) >= #{reminder_threshold}
SQL
end
end

View File

@ -31,12 +31,20 @@ RSpec.describe Jobs::EnqueueReminders do
assert_reminders_enqueued(1)
end
it "does not enqueue a reminder when the user only has one task" do
it "does not enqueue a reminder when the user has fewer assignments than `pending_assign_reminder_threshold`" do
assign_one_task_to(user)
assert_reminders_enqueued(0)
end
it "enqueues a reminder when the user has one assignement if `pending_assign_reminder_threshold` is set to one" do
assign_one_task_to(user)
SiteSetting.pending_assign_reminder_threshold = 1
assert_reminders_enqueued(1)
end
it "doesn't count assigns from deleted topics" do
deleted_post = Fabricate(:post)
assign_one_task_to(user, post: deleted_post)