From ab11e72ce5f0dac517c1d44df3188f9686821864 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Wed, 17 Feb 2016 02:37:43 -0300 Subject: [PATCH] app_queue: fix Calculate talktime when is first call answered Fix calculate of average time for talktime is wrong when is completed the first call beacuse the time for talked would be that call. ASTERISK-25800 #close Change-Id: I94f79028935913cd9174b090b52bb300b91b9492 --- apps/app_queue.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/app_queue.c b/apps/app_queue.c index 78ac4c5dcd..4a8029080d 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4950,9 +4950,13 @@ static int update_queue(struct call_queue *q, struct member *member, int callcom if (callcompletedinsl) { q->callscompletedinsl++; } - /* Calculate talktime using the same exponential average as holdtime code*/ - oldtalktime = q->talktime; - q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2; + if (q->callscompletedinsl == 1) { + q->talktime = newtalktime; + } else { + /* Calculate talktime using the same exponential average as holdtime code */ + oldtalktime = q->talktime; + q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2; + } ao2_unlock(q); return 0; } -- 2.47.2