mod_callcenter: Add a very prototype (and maybe not functional) strategy called : sequentially-by-next-agent-order.

It will try to find the last agent we tried to reach, and start calling more agent after that one based on position.
It will use the level for the next agent, but once that level is done, it start back at the lowest level
This commit is contained in:
Marc Olivier Chouinard 2011-04-17 12:46:32 -04:00
parent 5cc3b2e635
commit bef6f0f40d

View File

@ -1995,6 +1995,28 @@ static int members_callback(void *pArg, int argc, char **argv, char **columnName
cbt.record_template = queue_record_template; cbt.record_template = queue_record_template;
cbt.agent_found = SWITCH_FALSE; cbt.agent_found = SWITCH_FALSE;
if (!strcasecmp(queue->strategy, "sequentially-by-next-agent-order")) {
/* This is a quick attempt to continue to the last tried agent using the position order */
sql = switch_mprintf("SELECT system, name, status, contact, no_answer_count, max_no_answer, reject_delay_time, busy_delay_time, no_answer_delay_time, tiers.state, agents.last_bridge_end, agents.wrap_up_time, agents.state, agents.ready_time, tiers.level, agents.type, agents.uuid, tiers.position, agents.last_offered_call, 1 as dyn_order FROM agents LEFT JOIN tiers ON (agents.name = tiers.agent)"
" WHERE tiers.queue = '%q'"
" AND (agents.status = '%q' OR agents.status = '%q' OR agents.status = '%q')"
" AND tiers.position > (SELECT tiers.position FROM agents LEFT JOIN tiers ON (agents.name = tiers.agent) ORDER BY agents.last_offered_call WHERE tiers.queue = '%q' DESC LIMIT 1)"
" AND tiers.level = (SELECT tiers.level FROM agents LEFT JOIN tiers ON (agents.name = tiers.agent) WHERE tiers.queue = '%q' ORDER BY agents.last_offered_call DESC LIMIT 1)"
" UNION "
"SELECT system, name, status, contact, no_answer_count, max_no_answer, reject_delay_time, busy_delay_time, no_answer_delay_time, tiers.state, agents.last_bridge_end, agents.wrap_up_time, agents.state, agents.ready_time, tiers.level, agents.type, agents.uuid, tiers.position, agents.last_offered_call, 2 as dyn_order FROM agents LEFT JOIN tiers ON (agents.name = tiers.agent)"
" WHERE tiers.queue = '%q'"
" AND (agents.status = '%q' OR agents.status = '%q' OR agents.status = '%q')"
" ORDER BY dyn_order asc, tiers.level, tiers.position, agents.last_offered_call",
queue_name,
cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE), cc_agent_status2str(CC_AGENT_STATUS_ON_BREAK), cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE_ON_DEMAND),
queue_name,
queue_name,
queue_name,
cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE), cc_agent_status2str(CC_AGENT_STATUS_ON_BREAK), cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE_ON_DEMAND)
);
} else {
if (!strcasecmp(queue->strategy, "longest-idle-agent")) { if (!strcasecmp(queue->strategy, "longest-idle-agent")) {
sql_order_by = switch_mprintf("level, agents.last_offered_call, position"); sql_order_by = switch_mprintf("level, agents.last_offered_call, position");
} else if (!strcasecmp(queue_strategy, "agent-with-least-talk-time")) { } else if (!strcasecmp(queue_strategy, "agent-with-least-talk-time")) {
@ -2021,11 +2043,13 @@ static int members_callback(void *pArg, int argc, char **argv, char **columnName
queue_name, queue_name,
cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE), cc_agent_status2str(CC_AGENT_STATUS_ON_BREAK), cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE_ON_DEMAND), cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE), cc_agent_status2str(CC_AGENT_STATUS_ON_BREAK), cc_agent_status2str(CC_AGENT_STATUS_AVAILABLE_ON_DEMAND),
sql_order_by); sql_order_by);
switch_safe_free(sql_order_by);
}
cc_execute_sql_callback(NULL /* queue */, NULL /* mutex */, sql, agents_callback, &cbt /* Call back variables */); cc_execute_sql_callback(NULL /* queue */, NULL /* mutex */, sql, agents_callback, &cbt /* Call back variables */);
switch_safe_free(sql); switch_safe_free(sql);
switch_safe_free(sql_order_by);
/* We update a field in the queue struct so we can kick caller out if waiting for too long with no agent */ /* We update a field in the queue struct so we can kick caller out if waiting for too long with no agent */
if (!cbt.queue_name || !(queue = get_queue(cbt.queue_name))) { if (!cbt.queue_name || !(queue = get_queue(cbt.queue_name))) {