DEV: adds an option to check for working hours (#201)

This commit is contained in:
Joffrey JAFFEUX 2021-09-08 16:46:33 +02:00 committed by GitHub
parent cfc25d9ac2
commit 0881b638bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -89,3 +89,5 @@ en:
label: Hours between assignments
assigned_topic:
label: Assigned Topic ID
in_working_hours:
label: Users in working hours

View File

@ -665,6 +665,7 @@ after_initialize do
field :assignees_group, component: :group
field :assigned_topic, component: :text
field :minimum_time_between_assignments, component: :text
field :in_working_hours, component: :boolean
version 1
@ -732,10 +733,13 @@ after_initialize do
next
end
if fields.dig('in_working_hours', 'value')
assign_to_user_id = users_ids.shuffle.find do |user_id|
RandomAssignUtils.in_working_hours?(user_id)
end
end
assign_to_user_id ||= users_ids.sample
if assign_to_user_id.blank?
RandomAssignUtils.no_one!(topic_id, group.name)
next