]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix FS-7049 - Count and list agents based on their state
authorItalo Rossi <italorossib@gmail.com>
Wed, 3 Dec 2014 01:57:43 +0000 (22:57 -0300)
committerItalo Rossi <italorossib@gmail.com>
Wed, 3 Dec 2014 01:57:43 +0000 (22:57 -0300)
src/mod/applications/mod_callcenter/mod_callcenter.c

index 8d4c0caf06db0f94ab7227eb1ed0d556b2bb8f0f..7a34883345349fed82e0f441a752b1e99ba0379e 100644 (file)
@@ -3220,6 +3220,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
                                const char *sub_action = argv[0 + initial_argc];
                                const char *queue_name = argv[1 + initial_argc];
                                const char *status = NULL;
+                               const char *state = NULL;
                                struct list_result cbt;
 
                                /* queue list agents */
@@ -3227,7 +3228,13 @@ SWITCH_STANDARD_API(cc_config_api_function)
                                        if (argc-initial_argc > 2) {
                                                status = argv[2 + initial_argc];
                                        }
-                                       if (status)     {
+                                       if (argc-initial_argc > 3) {
+                                               state = argv[3 + initial_argc];
+                                       }
+                                       if (state)      {
+                                               sql = switch_mprintf("SELECT agents.* FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q' AND agents.status = '%q' AND agents.state = '%q'", queue_name, status, state);
+                                       }
+                                       else if (status)        {
                                                sql = switch_mprintf("SELECT agents.* FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q' AND agents.status = '%q'", queue_name, status);
                                        } else {
                                                sql = switch_mprintf("SELECT agents.* FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q'", queue_name);
@@ -3266,6 +3273,7 @@ SWITCH_STANDARD_API(cc_config_api_function)
                                const char *sub_action = argv[0 + initial_argc];
                                const char *queue_name = argv[1 + initial_argc];
                                const char *status = NULL;
+                               const char *state = NULL;
                                char res[256] = "";
 
                                /* queue count agents */
@@ -3273,7 +3281,13 @@ SWITCH_STANDARD_API(cc_config_api_function)
                                        if (argc-initial_argc > 2) {
                                                status = argv[2 + initial_argc];
                                        }
-                                       if (status)     {
+                                       if (argc-initial_argc > 3) {
+                                               state = argv[3 + initial_argc];
+                                       }
+                                       if (state)      {
+                                               sql = switch_mprintf("SELECT count(*) FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q' AND agents.status = '%q' AND agents.state = '%q'", queue_name, status, state);
+                                       }
+                                       else if (status)        {
                                                sql = switch_mprintf("SELECT count(*) FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q' AND agents.status = '%q'", queue_name, status);
                                        } else {
                                                sql = switch_mprintf("SELECT count(*) FROM agents,tiers WHERE tiers.agent = agents.name AND tiers.queue = '%q'", queue_name);