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.position as tiers_position, tiers.level as tiers_level, agents.type, agents.uuid, agents.last_offered_call as 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) WHERE tiers.queue = '%q' AND agents.last_offered_call > 0 ORDER BY agents.last_offered_call DESC LIMIT 1)"
" AND tiers.level = (SELECT tiers.level FROM agents LEFT JOIN tiers ON (agents.name = tiers.agent) WHERE tiers.queue = '%q' AND agents.last_offered_call > 0 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.position as tiers_position, tiers.level as tiers_level, agents.type, agents.uuid, agents.last_offered_call as 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",
sql_order_by=switch_mprintf("level, position, agents.last_offered_call");/* Default to last_offered_call, let add new strategy if needing it differently */
}else{
...
...
@@ -2014,18 +2080,20 @@ static int members_callback(void *pArg, int argc, char **argv, char **columnName
sql=switch_mprintf("SELECT abandoned_epoch FROM members WHERE uuid = '%q' AND session_uuid = '%q' AND state = '%q' AND queue = '%q'",member_session,member_session_uuid,cc_member_state2str(CC_MEMBER_STATE_WAITING),queue_name);
sql=switch_mprintf("SELECT abandoned_epoch FROM members WHERE uuid = '%q' AND session_uuid = '%q' AND state = '%q' AND queue = '%q'",member_uuid,member_session_uuid,cc_member_state2str(CC_MEMBER_STATE_WAITING),queue_name);
sql=switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'",user,realm,switch_core_get_hostname(),token);
}else{
sql=switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'",user,realm,switch_core_get_hostname());
}
switch_cache_db_execute_sql(dbh,sql,NULL);
switch_cache_db_release_db_handle(&dbh);
free(sql);
switch_queue_push(sql_manager.sql_queue[0],sql);
returnSWITCH_STATUS_SUCCESS;
}
...
...
@@ -1718,7 +1700,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, c