Skip to content

Commit

Permalink
FIX: Respect pending_assign_reminder_threshold in enqueue_reminders (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanlan committed May 10, 2024
1 parent e3c24ba commit 6978c75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/jobs/scheduled/enqueue_reminders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def allowed_group_ids
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 =
Expand Down Expand Up @@ -54,7 +58,7 @@ def user_ids
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
Expand Down
10 changes: 9 additions & 1 deletion spec/jobs/scheduled/enqueue_reminders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
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)
Expand Down

0 comments on commit 6978c75

Please sign in to comment.