Skip to content

Commit c955df4

Browse files
authored
Merge pull request #1090 from 1AhmedYasser/Feedback-Rating-Update
Feedback Rating Update
2 parents b51fc41 + 2429a73 commit c955df4

4 files changed

Lines changed: 317 additions & 251 deletions

File tree

DSL/Resql/users/POST/get-chat-by-id.sql

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
WITH chatById AS(
1+
WITH rating_config AS (
2+
SELECT value AS is_five_rating_scale
3+
FROM configuration
4+
WHERE key = 'isFiveRatingScale'
5+
AND id IN (SELECT max(id) FROM configuration WHERE key = 'isFiveRatingScale' GROUP BY key)
6+
AND NOT deleted
7+
),
8+
csa_title_config AS (
9+
SELECT value
10+
FROM configuration
11+
WHERE key = 'is_csa_title_visible'
12+
AND id IN (SELECT max(id) FROM configuration WHERE key = 'is_csa_title_visible' GROUP BY key)
13+
AND NOT deleted
14+
),
15+
chatById AS(
216
SELECT
317
base_id,
418
customer_support_id,
@@ -9,6 +23,7 @@ WITH chatById AS(
923
status,
1024
feedback_text,
1125
feedback_rating,
26+
feedback_rating_five,
1227
end_user_email,
1328
end_user_phone,
1429
end_user_os,
@@ -35,7 +50,11 @@ SELECT c.base_id AS id,
3550
c.end_user_last_name,
3651
c.status,
3752
c.feedback_text,
38-
c.feedback_rating,
53+
CASE
54+
WHEN (SELECT COALESCE(is_five_rating_scale, 'false') = 'true' FROM rating_config)
55+
THEN c.feedback_rating_five
56+
ELSE c.feedback_rating
57+
END AS feedback_rating,
3958
c.end_user_email,
4059
c.end_user_phone,
4160
c.end_user_os,
@@ -48,8 +67,10 @@ SELECT c.base_id AS id,
4867
c.received_from_name,
4968
c.forwarded_to_name,
5069
c.forwarded_to,
51-
(CASE WHEN (SELECT value FROM configuration WHERE key = 'is_csa_title_visible' AND configuration.id IN (SELECT max(id) from configuration GROUP BY key) AND NOT deleted) = 'true'
52-
THEN c.csa_title ELSE '' END) AS csa_title,
70+
(CASE WHEN (SELECT COALESCE(value, 'false') FROM csa_title_config) = 'true'
71+
THEN c.csa_title
72+
ELSE ''
73+
END) AS csa_title,
5374
m.content AS last_message,
5475
m.updated AS last_message_timestamp
5576
FROM chatById AS c

0 commit comments

Comments
 (0)