diff --git a/kamailio/nodes-role.cfg b/kamailio/nodes-role.cfg index 534a073..7fb20a7 100644 --- a/kamailio/nodes-role.cfg +++ b/kamailio/nodes-role.cfg @@ -45,13 +45,11 @@ route[NODES_ADVERTISE_ROUTE] #!ifdef PRESENCE_ROLE route(COUNT_ALL_SUBSCRIBERS); $var(Subscriptions) = $_s("Subscriptions" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); + $var(Subscribers) = $_s("Subscribers" : {"message-summary" : $xavp(watchers=>message-summary_unique), "dialog" : $xavp(watchers=>dialog_unique), "presence" : $xavp(watchers=>presence_unique)}); route(COUNT_ALL_PRESENTITIES); $var(Presentities) = $_s("Presentities" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); - route(COUNT_UNIQUE_SUBSCRIBERS); - $var(Subscribers) = $_s("Subscribers" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); - $var(Presence) = $_s("Presence" : {$var(Subscribers), $var(Subscriptions), $var(Presentities)}); #!else $var(Presence) = ""; diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 08705c9..471d1e9 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -209,12 +209,13 @@ route[COUNT_ALL_PRESENTITIES] route[COUNT_ALL_SUBSCRIBERS] { - $var(Query) = $_s(select event, (select count(*) from active_watchers b where b.event = a.event) count from event_list a); - $var(p) = $_s(uri=$var(presentity)); + $var(Query) = $_s(select a.event, count(distinct watcher_username || "@" || watcher_domain) count_unique, count(*) count from event_list a, active_watchers b where b.event = a.event group by a.event); + $var(p) = "uri=none"; if (sql_xquery("cb", "$var(Query)", "subs") == 1) { while($xavp(subs) != $null) { $var(p) = $var(p) + ";" + $xavp(subs=>event) + "=" + $xavp(subs=>count); + $var(p) = $var(p) + ";" + $xavp(subs=>event) + "_unique=" + $xavp(subs=>count_unique); pv_unset("$xavp(subs)"); } } @@ -235,20 +236,6 @@ route[COUNT_SUBSCRIBERS] xavp_params_explode($var(p), "watchers"); } -route[COUNT_UNIQUE_SUBSCRIBERS] -{ - $var(Query) = $_s(select event, (select count(distinct watcher_username || "@" || watcher_domain) from active_watchers b where b.event = a.event) count from event_list a); - $var(p) = "uri=none"; - if (sql_xquery("cb", "$var(Query)", "subs") == 1) - { - while($xavp(subs) != $null) { - $var(p) = $var(p) + ";" + $xavp(subs=>event) + "=" + $xavp(subs=>count); - pv_unset("$xavp(subs)"); - } - } - xavp_params_explode($var(p), "watchers"); -} - event_route[kazoo:consumer-event-presence-dialog-update] { $var(Now) = $TS;