By default, the reservation of Workers in a given TaskQueue is ordered by duration a Worker is unoccupied. Without an order_by expression, the Worker who has waited the longest without a Task will be the first reserved. An order_by expression allows you to designate an ordering for the Workers of a given TaskQueue based upon comparison of Workers' attributes.
The main building block of an order_by expression is an order_by clause, which is composed of:
An order_by expression may be composed of any number of order_by clauses. If several Workers have the same resolved value for the first order_by criterion, the second order_by clause will break the tie by comparing the next attribute. For example, let's think about a Workspace with the following:
"worker.finance ASC, worker.support ASC"
{finance = 10, support = 8}
{finance = 10, support = 5}
Alice and Bob are first compared using the first order_by clause, "worker.finance_level ASC"
, which results in a tie because their finance attributes are equal. To break the tie, the two Workers are next compared using the next order_by clause, "worker.support_level ASC"
. Bob's support level, 5, is less than Alice's support level, and the sort direction is ascending. When a new Task is created and enters this TaskQueue, the workers are ordered {Bob, Alice}, and Bob is reserved to handle the new Task.
What happens if a worker doesn't have a particular skill? Workers without a given skill are ordered after those that have a skill when there is a tie, regardless of whether "ASC" or "DESC" sort direction is selected. For example, given a Workspace containing:
"worker.finance ASC, worker.support ASC"
{finance = 10, support = 8}
{finance = 10}
Alice and Bob are first compared using the first order_by clause, "worker.finance_level ASC"
, which results in a tie because their finance attributes are equal. To break the tie, the two Workers are next compared using the next order_by clause, "worker.support_level ASC"
. Bob does not have the support attribute and will therefore appear in the queue after Alice. When a new Task is created and enters this TaskQueue, the workers are ordered {Alice, Bob}, and Alice is reserved to handle the new Task.
If ordering is attempted on a non-integer attribute, then the expression is ignored.
For workers that are equal, for all supplied ordering clauses, the longest time since last task assignment is used as a final ordering condition.
_22{_22 "task_routing":{_22 "filters":[_22 {_22 "filter_friendly_name":"Sales filter",_22 "expression":"type == 'Sales'",_22 "targets":[_22 {_22 "expression":"task.subSection = worker.specializedSubField",_22 "order_by":"worker.english_level ASC",_22 "priority":"1",_22 "queue":"WQ3935a4f744a241c1356c09310c2398e6"_22 },_22 {_22 "priority":"1",_22 "queue":"WQ787b271950e0f7687ec432221e672ffa"_22 }_22 ]_22 }_22 ]_22 }_22}