mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-10-27 14:57:02 +00:00
count only each conversation's latest applied sla in overview report
This commit is contained in:
@@ -73,7 +73,13 @@ WHERE
|
||||
s.category != 'resolved';
|
||||
|
||||
-- name: get-overview-sla-counts
|
||||
WITH first_and_resolution AS (
|
||||
-- Count only each conversation's latest applied SLA; superseded rows are kept as history and would double-count.
|
||||
WITH latest_applied AS (
|
||||
SELECT DISTINCT ON (conversation_id) *
|
||||
FROM applied_slas
|
||||
ORDER BY conversation_id, created_at DESC, id DESC
|
||||
),
|
||||
first_and_resolution AS (
|
||||
SELECT
|
||||
COUNT(*) FILTER (
|
||||
WHERE
|
||||
@@ -118,7 +124,7 @@ WITH first_and_resolution AS (
|
||||
0
|
||||
) AS avg_resolution_time_sec
|
||||
FROM
|
||||
applied_slas
|
||||
latest_applied
|
||||
WHERE
|
||||
created_at >= CASE
|
||||
WHEN %d = 0 THEN CURRENT_DATE
|
||||
|
||||
Reference in New Issue
Block a user