mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-23 19:06:35 +00:00
fix: exclude sent messages from report/dashboard charts to avoid data skew
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<LineChart :data="data" index="date" :categories="['New conversations', 'Resolved conversations', 'Messages sent']"
|
||||
<LineChart :data="data" index="date" :categories="['New conversations', 'Resolved conversations']"
|
||||
:x-formatter="xFormatter" :y-formatter="yFormatter" />
|
||||
</template>
|
||||
|
||||
|
||||
@@ -138,8 +138,6 @@ const getDashboardCharts = async () => {
|
||||
chartData.value.new_conversations.find((item) => item.date === date)?.count || 0,
|
||||
'Resolved conversations':
|
||||
chartData.value.resolved_conversations.find((item) => item.date === date)?.count || 0,
|
||||
'Messages sent':
|
||||
chartData.value.messages_sent.find((item) => item.date === date)?.count || 0
|
||||
}))
|
||||
|
||||
chartData.value.status_summary = resp.data.data.status_summary || []
|
||||
|
||||
@@ -311,26 +311,10 @@ status_summary AS (
|
||||
GROUP BY
|
||||
s.name
|
||||
) agg
|
||||
),
|
||||
messages_sent as (
|
||||
SELECT json_agg(row_to_json(agg)) AS data
|
||||
FROM (
|
||||
SELECT
|
||||
TO_CHAR(created_at::date, 'YYYY-MM-DD') AS date,
|
||||
COUNT(*) AS count
|
||||
FROM
|
||||
conversation_messages c
|
||||
WHERE status = 'sent' AND 1=1 %s
|
||||
GROUP BY
|
||||
date
|
||||
ORDER BY
|
||||
date
|
||||
) agg
|
||||
)
|
||||
SELECT json_build_object(
|
||||
'new_conversations', (SELECT data FROM new_conversations),
|
||||
'resolved_conversations', (SELECT data FROM resolved_conversations),
|
||||
'messages_sent', (SELECT data FROM messages_sent),
|
||||
'status_summary', (SELECT data FROM status_summary)
|
||||
) AS result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user