-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved common elements to analytics module * Updated base elements and stylings, added and updated missing queries * updated view button logic * Updated SQL to fetch coversations, updated page to display conversation that been taken
- Loading branch information
Showing
3 changed files
with
94 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,62 @@ | ||
WITH n_chats AS ( | ||
SELECT | ||
SELECT | ||
base_id, | ||
MAX(created) AS created | ||
FROM chat | ||
WHERE STATUS = 'ENDED' | ||
AND created::date BETWEEN :start::date AND :end::date | ||
AND feedback_rating IS NOT NULL | ||
AND feedback_rating <= 5 | ||
GROUP BY base_id | ||
), | ||
c_chat AS ( | ||
SELECT | ||
base_id, | ||
MAX(created) AS created | ||
FROM chat | ||
WHERE STATUS = 'ENDED' | ||
AND created::date BETWEEN :start::date AND :end::date | ||
AND feedback_rating IS NOT NULL | ||
AND feedback_rating <= 5 | ||
GROUP BY base_id | ||
), | ||
c_chat AS ( | ||
SELECT base_id, | ||
MIN(created) AS created, | ||
MAX(ended) AS ended | ||
FROM chat | ||
GROUP BY base_id | ||
) | ||
SELECT n_chats.base_id, | ||
c_chat.created, | ||
c_chat.ended, | ||
chat.feedback_rating AS rating, | ||
chat.feedback_text AS feedback, | ||
CEIL(COUNT(*) OVER() / :page_size::DECIMAL) AS total_pages | ||
FROM chat | ||
GROUP BY base_id | ||
), | ||
deduplicated_users AS ( | ||
SELECT | ||
id_code, | ||
first_name, | ||
last_name | ||
FROM ( | ||
SELECT | ||
id_code, | ||
first_name, | ||
last_name, | ||
ROW_NUMBER() OVER (PARTITION BY id_code ORDER BY first_name, last_name) AS row_num | ||
FROM "user" | ||
) AS ranked_users | ||
WHERE row_num = 1 | ||
) | ||
SELECT | ||
n_chats.base_id, | ||
c_chat.created, | ||
c_chat.ended, | ||
chat.feedback_rating AS rating, | ||
chat.feedback_text AS feedback, | ||
deduplicated_users.first_name AS first_name, | ||
deduplicated_users.last_name AS last_name, | ||
CEIL(COUNT(*) OVER() / :page_size::DECIMAL) AS total_pages | ||
FROM n_chats | ||
LEFT JOIN chat ON n_chats.base_id = chat.base_id | ||
JOIN c_chat ON c_chat.base_id = chat.base_id AND n_chats.created = chat.created | ||
LEFT JOIN chat ON n_chats.base_id = chat.base_id | ||
LEFT JOIN c_chat ON c_chat.base_id = chat.base_id AND n_chats.created = chat.created | ||
LEFT JOIN deduplicated_users ON chat.customer_support_id = deduplicated_users.id_code | ||
WHERE chat.feedback_rating IS NOT NULL | ||
AND chat.ended IS NOT NULL | ||
ORDER BY | ||
CASE WHEN :sorting = 'created desc' THEN n_chats.created END DESC, | ||
CASE WHEN :sorting = 'created asc' THEN n_chats.created END ASC, | ||
CASE WHEN :sorting = 'ended desc' THEN n_chats.created END DESC, | ||
CASE WHEN :sorting = 'ended asc' THEN n_chats.created END ASC, | ||
CASE WHEN :sorting = 'base_id desc' THEN n_chats.base_id END DESC, | ||
CASE WHEN :sorting = 'base_id asc' THEN n_chats.base_id END ASC, | ||
CASE WHEN :sorting = 'feedback desc' THEN feedback_text END DESC, | ||
CASE WHEN :sorting = 'feedback asc' THEN feedback_text END ASC, | ||
CASE WHEN :sorting = 'rating desc' THEN feedback_rating END DESC, | ||
CASE WHEN :sorting = 'rating asc' THEN feedback_rating END ASC | ||
OFFSET ((GREATEST(:page, 1) - 1) * :page_size) LIMIT :page_size; | ||
AND chat.ended IS NOT NULL | ||
ORDER BY | ||
CASE WHEN :sorting = 'created desc' THEN n_chats.created END DESC, | ||
CASE WHEN :sorting = 'created asc' THEN n_chats.created END ASC, | ||
CASE WHEN :sorting = 'ended desc' THEN n_chats.created END DESC, | ||
CASE WHEN :sorting = 'ended asc' THEN n_chats.created END ASC, | ||
CASE WHEN :sorting = 'base_id desc' THEN n_chats.base_id END DESC, | ||
CASE WHEN :sorting = 'base_id asc' THEN n_chats.base_id END ASC, | ||
CASE WHEN :sorting = 'feedback desc' THEN feedback_text END DESC, | ||
CASE WHEN :sorting = 'feedback asc' THEN feedback_text END ASC, | ||
CASE WHEN :sorting = 'rating desc' THEN feedback_rating END DESC, | ||
CASE WHEN :sorting = 'rating asc' THEN feedback_rating END ASC | ||
OFFSET ((GREATEST(:page, 1) - 1) * :page_size) | ||
LIMIT :page_size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ROLES } from 'utils/constants'; | ||
|
||
export interface User { | ||
login?: string; | ||
fullName?: string; | ||
firstName: string; | ||
lastName: string; | ||
idCode: string; | ||
displayName: string; | ||
csaTitle: string; | ||
csaEmail: string; | ||
authorities: ROLES[]; | ||
customerSupportStatus: 'online' | 'idle' | 'offline'; | ||
} | ||
|
||
export interface UserDTO extends Pick<User, 'login' | 'firstName' | 'lastName' | 'fullName' | 'idCode' | 'authorities' | 'displayName' | 'csaTitle' | 'csaEmail'> { | ||
} | ||
|
||
export interface UserSearchFilters { | ||
search_full_name: string; | ||
search_id_code: string; | ||
search_display_name: string; | ||
search_csa_title: string; | ||
search_csa_email: string; | ||
search_authority: string; | ||
} |