FEATURE: Add pending assign reminder threshold setting (#571)
* FEATURE: Add pending assign reminder threshold setting User can define a threshold for the pending assign reminder. * DEV: rename REMINDER_THRESHOLD with SiteSetting
This commit is contained in:
parent
6c229284a9
commit
e3c24ba2f2
|
@ -14,6 +14,7 @@ en:
|
||||||
assign_mailer: "When to send notification email for assignments"
|
assign_mailer: "When to send notification email for assignments"
|
||||||
remind_assigns: "Remind users about pending assigns."
|
remind_assigns: "Remind users about pending assigns."
|
||||||
remind_assigns_frequency: "Frequency for reminding users about assigned topics."
|
remind_assigns_frequency: "Frequency for reminding users about assigned topics."
|
||||||
|
pending_assign_reminder_threshold: "Number of pending assignments that triggers a reminder notification."
|
||||||
max_assigned_topics: "Maximum number of topics that can be assigned to a user."
|
max_assigned_topics: "Maximum number of topics that can be assigned to a user."
|
||||||
assign_allowed_on_groups: "Users in these groups are allowed to assign topics and can be assigned topics."
|
assign_allowed_on_groups: "Users in these groups are allowed to assign topics and can be assigned topics."
|
||||||
enable_assign_status: "Add a customizable status field to every assignment."
|
enable_assign_status: "Add a customizable status field to every assignment."
|
||||||
|
|
|
@ -23,6 +23,10 @@ discourse_assign:
|
||||||
client: true
|
client: true
|
||||||
enum: "RemindAssignsFrequencySiteSettings"
|
enum: "RemindAssignsFrequencySiteSettings"
|
||||||
default: 0
|
default: 0
|
||||||
|
pending_assign_reminder_threshold:
|
||||||
|
client: true
|
||||||
|
default: 2
|
||||||
|
min: 1
|
||||||
max_assigned_topics:
|
max_assigned_topics:
|
||||||
client: true
|
client: true
|
||||||
default: 10
|
default: 10
|
||||||
|
|
|
@ -4,11 +4,10 @@ class PendingAssignsReminder
|
||||||
REMINDED_AT = "last_reminded_at"
|
REMINDED_AT = "last_reminded_at"
|
||||||
REMINDERS_FREQUENCY = "remind_assigns_frequency"
|
REMINDERS_FREQUENCY = "remind_assigns_frequency"
|
||||||
CUSTOM_FIELD_NAME = "assigns_reminder"
|
CUSTOM_FIELD_NAME = "assigns_reminder"
|
||||||
REMINDER_THRESHOLD = 2
|
|
||||||
|
|
||||||
def remind(user)
|
def remind(user)
|
||||||
newest_topics = assigned_topics(user, order: :desc)
|
newest_topics = assigned_topics(user, order: :desc)
|
||||||
return if newest_topics.size < REMINDER_THRESHOLD
|
return if newest_topics.size < SiteSetting.pending_assign_reminder_threshold
|
||||||
|
|
||||||
delete_previous_reminders(user)
|
delete_previous_reminders(user)
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe Jobs::EnqueueReminders do
|
||||||
it "doesn't count assigns from deleted topics" do
|
it "doesn't count assigns from deleted topics" do
|
||||||
deleted_post = Fabricate(:post)
|
deleted_post = Fabricate(:post)
|
||||||
assign_one_task_to(user, post: deleted_post)
|
assign_one_task_to(user, post: deleted_post)
|
||||||
(PendingAssignsReminder::REMINDER_THRESHOLD - 1).times { assign_one_task_to(user) }
|
(SiteSetting.pending_assign_reminder_threshold - 1).times { assign_one_task_to(user) }
|
||||||
|
|
||||||
deleted_post.topic.trash!
|
deleted_post.topic.trash!
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ RSpec.describe Jobs::EnqueueReminders do
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_multiple_tasks_to(user, assigned_on: 3.months.ago)
|
def assign_multiple_tasks_to(user, assigned_on: 3.months.ago)
|
||||||
PendingAssignsReminder::REMINDER_THRESHOLD.times do
|
SiteSetting.pending_assign_reminder_threshold.times do
|
||||||
assign_one_task_to(user, assigned_on: assigned_on)
|
assign_one_task_to(user, assigned_on: assigned_on)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue