From 26a21923fc0774065834510318289dc78323b82d Mon Sep 17 00:00:00 2001 From: VassiliMoskaljov Date: Mon, 30 Dec 2024 17:11:27 +0200 Subject: [PATCH 1/2] Updated Sql to fix sorting --- DSL/Resql/get-cs-all-ended-chats.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DSL/Resql/get-cs-all-ended-chats.sql b/DSL/Resql/get-cs-all-ended-chats.sql index e54fa5e0..acda8d45 100644 --- a/DSL/Resql/get-cs-all-ended-chats.sql +++ b/DSL/Resql/get-cs-all-ended-chats.sql @@ -201,8 +201,12 @@ ORDER BY CASE WHEN :sorting = 'comment desc' THEN s.comment END DESC, CASE WHEN :sorting = 'labels asc' THEN c.labels END ASC, CASE WHEN :sorting = 'labels desc' THEN c.labels END DESC, - CASE WHEN :sorting = 'status asc' THEN c.status END ASC, - CASE WHEN :sorting = 'status desc' THEN c.status END DESC, + CASE WHEN :sorting = 'status asc' THEN m.event END ASC NULLS LAST, + CASE WHEN :sorting = 'status desc' THEN m.event END DESC NULLS LAST, + CASE WHEN :sorting = 'feedbackRating desc' THEN c.feedback_rating END DESC NULLS LAST, + CASE WHEN :sorting = 'feedbackRating asc' THEN c.feedback_rating END ASC, + CASE WHEN :sorting = 'customerSupportFullName desc' THEN (cu.first_name || ' ' || cu.last_name) END DESC NULLS LAST, + CASE WHEN :sorting = 'customerSupportFullName asc' THEN (cu.first_name || ' ' || cu.last_name) END ASC NULLS LAST, CASE WHEN :sorting = 'id asc' THEN c.base_id END ASC, CASE WHEN :sorting = 'id desc' THEN c.base_id END DESC OFFSET ((GREATEST(:page, 1) - 1) * :page_size) LIMIT :page_size; From 2f03f5a95bc05853687a08f3b9d9081e30489da5 Mon Sep 17 00:00:00 2001 From: VassiliMoskaljov Date: Tue, 31 Dec 2024 10:31:03 +0200 Subject: [PATCH 2/2] Added empty string to appear last --- DSL/Resql/get-cs-all-ended-chats.sql | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DSL/Resql/get-cs-all-ended-chats.sql b/DSL/Resql/get-cs-all-ended-chats.sql index acda8d45..5092bb27 100644 --- a/DSL/Resql/get-cs-all-ended-chats.sql +++ b/DSL/Resql/get-cs-all-ended-chats.sql @@ -201,8 +201,20 @@ ORDER BY CASE WHEN :sorting = 'comment desc' THEN s.comment END DESC, CASE WHEN :sorting = 'labels asc' THEN c.labels END ASC, CASE WHEN :sorting = 'labels desc' THEN c.labels END DESC, - CASE WHEN :sorting = 'status asc' THEN m.event END ASC NULLS LAST, - CASE WHEN :sorting = 'status desc' THEN m.event END DESC NULLS LAST, + CASE + WHEN :sorting = 'status asc' THEN + CASE + WHEN m.event IS NULL OR m.event = '' THEN NULL + ELSE m.event + END + END ASC NULLS LAST, + CASE + WHEN :sorting = 'status desc' THEN + CASE + WHEN m.event IS NULL OR m.event = '' THEN NULL + ELSE m.event + END + END DESC NULLS LAST, CASE WHEN :sorting = 'feedbackRating desc' THEN c.feedback_rating END DESC NULLS LAST, CASE WHEN :sorting = 'feedbackRating asc' THEN c.feedback_rating END ASC, CASE WHEN :sorting = 'customerSupportFullName desc' THEN (cu.first_name || ' ' || cu.last_name) END DESC NULLS LAST,