Skip to content

Commit 7fe477e

Browse files
authoredJun 20, 2024
Merge pull request buerokratt#720 from 1AhmedYasser/fixes-in-chat-history
Fixes in chat history
2 parents 57af8b3 + 461a165 commit 7fe477e

File tree

4 files changed

+57
-24
lines changed

4 files changed

+57
-24
lines changed
 

‎DSL/Resql/get-cs-all-ended-chats.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Detractors AS (
105105
SELECT COUNT(rating) AS d FROM RatedChats WHERE rating <= 6
106106
),
107107
NPS AS (
108-
SELECT ROUND(((p / (total * 1.0)) - (d / (total * 1.0))) * 100.0, 2) AS nps
108+
SELECT ROUND(((p / (GREATEST(total, 1) * 1.0)) - (d / (GREATEST(total, 1) * 1.0))) * 100.0, 2) AS nps
109109
FROM RatedChatsCount
110110
CROSS JOIN Promoters
111111
CROSS JOIN Detractors

‎GUI/src/components/DataTable/index.tsx

+19-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
TableMeta,
1515
Row,
1616
RowData, ColumnFiltersState,
17+
ColumnPinningState,
1718
} from '@tanstack/react-table';
1819
import {
1920
RankingInfo,
@@ -43,6 +44,7 @@ type DataTableProps = {
4344
filterable?: boolean;
4445
pagination?: PaginationState;
4546
sorting?: SortingState;
47+
columnPinning?: ColumnPinningState;
4648
setPagination?: (state: PaginationState) => void;
4749
setSorting?: (state: SortingState) => void;
4850
globalFilter?: string;
@@ -57,8 +59,9 @@ type DataTableProps = {
5759
type ColumnMeta = {
5860
meta: {
5961
size: number | string;
60-
}
61-
}
62+
sticky: 'left' | 'right';
63+
};
64+
};
6265

6366
type CustomColumnDef = ColumnDef<any> & ColumnMeta;
6467

@@ -99,6 +102,7 @@ const DataTable: FC<DataTableProps> = (
99102
filterable,
100103
pagination,
101104
sorting,
105+
columnPinning,
102106
setPagination,
103107
setSorting,
104108
globalFilter,
@@ -123,9 +127,14 @@ const DataTable: FC<DataTableProps> = (
123127
sorting,
124128
columnFilters,
125129
globalFilter,
130+
columnPinning: columnPinning ?? {
131+
left: [],
132+
right: [],
133+
},
126134
columnVisibility,
127135
...{ pagination },
128136
},
137+
enableColumnPinning: columnPinning != undefined ? true : false,
129138
meta,
130139
onColumnFiltersChange: setColumnFilters,
131140
onGlobalFilterChange: setGlobalFilter,
@@ -156,7 +165,10 @@ const DataTable: FC<DataTableProps> = (
156165
{table.getHeaderGroups().map((headerGroup) => (
157166
<tr key={headerGroup.id}>
158167
{headerGroup.headers.map((header) => (
159-
<th key={header.id} style={{ width: header.column.columnDef.meta?.size }}>
168+
<th key={header.id} style={{ width: header.column.columnDef.meta?.size, position: header.column.columnDef.meta?.sticky ? 'sticky' : undefined ,
169+
left: header.column.columnDef.meta?.sticky === 'left' ? `${header.column.getAfter('left') * 0.675}px` : undefined,
170+
right: header.column.columnDef.meta?.sticky === 'right' ? `${header.column.getAfter('right') * 0.675}px` : undefined,
171+
backgroundColor: 'white', zIndex: header.column.columnDef.meta?.sticky ? 1 : 0 }}>
160172
{header.isPlaceholder ? null : (
161173
<Track gap={8}>
162174
{sortable && header.column.getCanSort() && (
@@ -186,7 +198,10 @@ const DataTable: FC<DataTableProps> = (
186198
{table.getRowModel().rows.map((row) => (
187199
<tr key={row.id} style={table.options.meta?.getRowStyles(row)}>
188200
{row.getVisibleCells().map((cell) => (
189-
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
201+
<td key={cell.id} style={{position: cell.column.columnDef.meta?.sticky ? 'sticky' : undefined ,
202+
left: cell.column.columnDef.meta?.sticky === 'left' ? `${cell.column.getAfter('left') * 0.675}px` : undefined,
203+
right: cell.column.columnDef.meta?.sticky === 'right' ? `${cell.column.getAfter('right') * 0.675}px` : undefined,
204+
backgroundColor: 'white', zIndex: cell.column.columnDef.meta?.sticky ? 1 : 0}} >{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
190205
))}
191206
</tr>
192207
))}

‎GUI/src/pages/Chat/ChatHistory/index.tsx

+35-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FC, useEffect, useMemo, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { useMutation } from '@tanstack/react-query';
44
import {
5+
ColumnPinningState,
56
createColumnHelper,
67
PaginationState,
78
SortingState,
@@ -62,6 +63,10 @@ const ChatHistory: FC = () => {
6263
pageSize: 10,
6364
});
6465
const [sorting, setSorting] = useState<SortingState>([]);
66+
const columnPinning: ColumnPinningState = {
67+
left: [],
68+
right: ['detail'],
69+
};
6570
const [totalPages, setTotalPages] = useState<number>(1);
6671
const [endedChatsList, setEndedChatsList] = useState<ChatType[]>([]);
6772
const [filteredEndedChatsList, setFilteredEndedChatsList] = useState<
@@ -271,23 +276,30 @@ const ChatHistory: FC = () => {
271276
};
272277

273278
const commentView = (props: any) =>
274-
props.getValue() && <Tooltip content={props.getValue()}>
275-
<span onClick={() => copyValueToClipboard(props.getValue())} style={{ cursor: 'pointer' }}>
276-
{props.getValue().length <= 30 ? props.getValue() : `${props.getValue()?.slice(0, 30)}...`}
277-
</span>
278-
</Tooltip>;
279+
props.getValue() && (
280+
<Tooltip content={props.getValue()}>
281+
<span
282+
onClick={() => copyValueToClipboard(props.getValue())}
283+
style={{ cursor: 'pointer' }}
284+
>
285+
{props.getValue().length <= 30
286+
? props.getValue()
287+
: `${props.getValue()?.slice(0, 30)}...`}
288+
</span>
289+
</Tooltip>
290+
);
279291

280-
const feedbackTextView = (props: any) => {
292+
const feedbackTextView = (props: any) => {
281293
const value = props.getValue() ?? '';
282-
294+
283295
return (
284296
<Tooltip content={value}>
285297
<span style={{ minWidth: '250px' }}>
286-
{value.length < 30 ? value : `${value?.slice?.(0, 30)}...`}
298+
{value.length < 30 ? value : `${value?.slice?.(0, 30)}...`}
287299
</span>
288300
</Tooltip>
289-
)
290-
}
301+
);
302+
};
291303

292304
const statusView = (props: any) => {
293305
const isLastMessageEvent =
@@ -300,7 +312,10 @@ const ChatHistory: FC = () => {
300312

301313
const idView = (props: any) => (
302314
<Tooltip content={props.getValue()}>
303-
<span onClick={() => copyValueToClipboard(props.getValue())} style={{ cursor: 'pointer' }}>
315+
<span
316+
onClick={() => copyValueToClipboard(props.getValue())}
317+
style={{ cursor: 'pointer' }}
318+
>
304319
{props.getValue().split('-')[0]}
305320
</span>
306321
</Tooltip>
@@ -324,8 +339,8 @@ const ChatHistory: FC = () => {
324339
cell: (props) =>
325340
format(
326341
new Date(props.getValue()),
327-
'd. MMM yyyy HH:mm:ss',
328-
i18n.language === 'et' ? { locale: et } : undefined,
342+
'dd.MM.yyyy HH:mm:ss',
343+
i18n.language === 'et' ? { locale: et } : undefined
329344
),
330345
}),
331346
columnHelper.accessor('ended', {
@@ -334,8 +349,8 @@ const ChatHistory: FC = () => {
334349
cell: (props) =>
335350
format(
336351
new Date(props.getValue()),
337-
'd. MMM yyyy HH:mm:ss',
338-
i18n.language === 'et' ? { locale: et } : undefined,
352+
'dd.MM.yyyy HH:mm:ss',
353+
i18n.language === 'et' ? { locale: et } : undefined
339354
),
340355
}),
341356
columnHelper.accessor('customerSupportDisplayName', {
@@ -366,12 +381,13 @@ const ChatHistory: FC = () => {
366381
columnHelper.accessor('feedbackRating', {
367382
id: 'feedbackRating',
368383
header: t('chat.history.rating') ?? '',
369-
cell: (props) => props.getValue() && <span>{`${props.getValue()}/10`}</span>,
384+
cell: (props) =>
385+
props.getValue() && <span>{`${props.getValue()}/10`}</span>,
370386
}),
371387
columnHelper.accessor('feedbackText', {
372388
id: 'feedbackText',
373389
header: t('chat.history.feedback') ?? '',
374-
cell: feedbackTextView
390+
cell: feedbackTextView,
375391
}),
376392
columnHelper.accessor('status', {
377393
id: 'status',
@@ -404,6 +420,7 @@ const ChatHistory: FC = () => {
404420
cell: detailsView,
405421
meta: {
406422
size: '1%',
423+
sticky: 'right',
407424
},
408425
}),
409426
],
@@ -540,6 +557,7 @@ const ChatHistory: FC = () => {
540557
sortable
541558
columns={getFilteredColumns()}
542559
pagination={pagination}
560+
columnPinning={columnPinning}
543561
sorting={sorting}
544562
setPagination={(state: PaginationState) => {
545563
if (

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ For production deploying on kubernetes use this the variable [`REACT_APP_MENU_JS
7676
```
7777
like this:
7878
```
79-
- name: REACT_APP_MENU_JSON
80-
value: "[{\"id\":\"conversations\",\"label\":{\"et\":\"Vestlused\",\"en\":\"Conversations\"},\"path\":\"/chat\",\"children\":[{\"label\":{\"et\":\"Vastamata\",\"en\":\"Unanswered\"},\"path\":\"/unanswered\"},{\"label\":{\"et\":\"Aktiivsed\",\"en\":\"Active\"},\"path\":\"/active\"},{\"label\":{\"et\":\"Ootel\",\"en\":\"Pending\"},\"path\":\"/pending\"},{\"label\":{\"et\":\"Ajalugu\",\"en\":\"History\"},\"path\":\"/history\"}]},{\"id\":\"training\",\"label\":{\"et\":\"Treening\",\"en\":\"Training\"},\"path\":\"/training\",\"children\":[{\"label\":{\"et\":\"Treening\",\"en\":\"Training\"},\"path\":\"/training\",\"children\":[{\"label\":{\"et\":\"Teemad\",\"en\":\"Themes\"},\"path\":\"/training/intents\"},{\"hidden\":true,\"label\":{\"et\":\"Avalikud teemad\",\"en\":\"Public themes\"},\"path\":\"/training/common-intents\"},{\"label\":{\"et\":\"Teemade järeltreenimine\",\"en\":\"Post training themes\"},\"path\":\"/training/intents-followup-training\"},{\"label\":{\"et\":\"Vastused\",\"en\":\"Answers\"},\"path\":\"/training/responses\"},{\"label\":{\"et\":\"Kasutuslood\",\"en\":\"User Stories\"},\"path\":\"/training/stories\"},{\"hidden\":true,\"label\":{\"et\":\"Konfiguratsioon\",\"en\":\"Configuration\"},\"path\":\"/training/configuration\"},{\"label\":{\"et\":\"Vormid\",\"en\":\"Forms\"},\"path\":\"/training/forms\"},{\"label\":{\"et\":\"Mälukohad\",\"en\":\"Slots\"},\"path\":\"/training/slots\"},{\"hidden\":true,\"label\":{\"et\":\"Automatic Teenused\",\"en\":\"Automatic Services\"},\"path\":\"/auto-services\"}]},{\"label\":{\"et\":\"Ajaloolised vestlused\",\"en\":\"Historical conversations\"},\"path\":\"/history\",\"children\":[{\"label\":{\"et\":\"Ajalugu\",\"en\":\"History\"},\"path\":\"/history/history\"},{\"hidden\":true,\"label\":{\"et\":\"Pöördumised\",\"en\":\"Appeals\"},\"path\":\"/history/appeal\"}]},{\"label\":{\"et\":\"Mudelipank ja analüütika\",\"en\":\"Modelbank and analytics\"},\"path\":\"/analytics\",\"children\":[{\"label\":{\"et\":\"Teemade ülevaade\",\"en\":\"Overview of topics\"},\"path\":\"/analytics/overview\"},{\"label\":{\"et\":\"Mudelite võrdlus\",\"en\":\"Comparison of models\"},\"path\":\"/analytics/models\"},{\"hidden\":true,\"label\":{\"et\":\"Testlood\",\"en\":\"testTracks\"},\"path\":\"/analytics/testcases\"}]},{\"label\":{\"et\":\"Treeni uus mudel\",\"en\":\"Train new model\"},\"path\":\"/train-new-model\"}]},{\"id\":\"analytics\",\"label\":{\"et\":\"Analüütika\",\"en\":\"Analytics\"},\"path\":\"/analytics\",\"children\":[{\"label\":{\"et\":\"Ülevaade\",\"en\":\"Overview\"},\"path\":\"/overview\"},{\"label\":{\"et\":\"Vestlused\",\"en\":\"Chats\"},\"path\":\"/chats\"},{\"label\":{\"et\":\"Tagasiside\",\"en\":\"Feedback\"},\"path\":\"/feedback\"},{\"label\":{\"et\":\"Nõustajad\",\"en\":\"Advisors\"},\"path\":\"/advisors\"},{\"label\":{\"et\":\"Avaandmed\",\"en\":\"Reports\"},\"path\":\"/reports\"}]},{\"id\":\"services\",\"hidden\":true,\"label\":{\"et\":\"Teenused\",\"en\":\"Services\"},\"path\":\"/services\",\"children\":[{\"label\":{\"et\":\"Ülevaade\",\"en\":\"Overview\"},\"path\":\"/overview\"},{\"label\":{\"et\":\"Uus teenus\",\"en\":\"New Service\"},\"path\":\"/newService\"},{\"label\":{\"et\":\"Automatic Teenused\",\"en\":\"Automatic Services\"},\"path\":\"/auto-services\"},{\"label\":{\"et\":\"Probleemsed teenused\",\"en\":\"Faulty Services\"},\"path\":\"/faultyServices\"}]},{\"id\":\"settings\",\"label\":{\"et\":\"Haldus\",\"en\":\"Administration\"},\"path\":\"/settings\",\"children\":[{\"label\":{\"et\":\"Kasutajad\",\"en\":\"Users\"},\"path\":\"/users\"},{\"label\":{\"et\":\"Vestlusbot\",\"en\":\"Chatbot\"},\"path\":\"/chatbot\",\"children\":[{\"label\":{\"et\":\"Seaded\",\"en\":\"Settings\"},\"path\":\"/chatbot/settings\"},{\"label\":{\"et\":\"Tervitussõnum\",\"en\":\"Welcome message\"},\"path\":\"/chatbot/welcome-message\"},{\"label\":{\"et\":\"Välimus ja käitumine\",\"en\":\"Appearance and behavior\"},\"path\":\"/chatbot/appearance\"},{\"label\":{\"et\":\"Erakorralised teated\",\"en\":\"Emergency notices\"},\"path\":\"/chatbot/emergency-notices\"}]},{\"label\":{\"et\":\"Asutuse tööaeg\",\"en\":\"Office opening hours\"},\"path\":\"/working-time\"},{\"label\":{\"et\":\"Sessiooni pikkus\",\"en\":\"Session length\"},\"path\":\"/session-length\"}]},{\"id\":\"monitoring\",\"hidden\":true,\"label\":{\"et\":\"Seire\",\"en\":\"Monitoring\"},\"path\":\"/monitoring\",\"children\":[{\"label\":{\"et\":\"Aktiivaeg\",\"en\":\"Working hours\"},\"path\":\"/uptime\"}]}]"
79+
- name: REACT_APP_MENU_JSON
80+
value: "[{\"id\":\"conversations\",\"label\":{\"et\":\"Vestlused\",\"en\":\"Conversations\"},\"path\":\"/chat\",\"children\":[{\"label\":{\"et\":\"Vastamata\",\"en\":\"Unanswered\"},\"path\":\"/unanswered\"},{\"label\":{\"et\":\"Aktiivsed\",\"en\":\"Active\"},\"path\":\"/active\"},{\"label\":{\"et\":\"Ootel\",\"en\":\"Pending\"},\"path\":\"/pending\"},{\"label\":{\"et\":\"Ajalugu\",\"en\":\"History\"},\"path\":\"/history\"}]},{\"id\":\"training\",\"label\":{\"et\":\"Treening\",\"en\":\"Training\"},\"path\":\"/training\",\"children\":[{\"label\":{\"et\":\"Treening\",\"en\":\"Training\"},\"path\":\"/training\",\"children\":[{\"label\":{\"et\":\"Teemad\",\"en\":\"Themes\"},\"path\":\"/training/intents\"},{\"hidden\":true,\"label\":{\"et\":\"Avalikud teemad\",\"en\":\"Public themes\"},\"path\":\"/training/common-intents\"},{\"label\":{\"et\":\"Teemade järeltreenimine\",\"en\":\"Post training themes\"},\"path\":\"/training/intents-followup-training\"},{\"label\":{\"et\":\"Vastused\",\"en\":\"Answers\"},\"path\":\"/training/responses\"},{\"label\":{\"et\":\"Kasutuslood\",\"en\":\"User Stories\"},\"path\":\"/training/stories\"},{\"hidden\":true,\"label\":{\"et\":\"Konfiguratsioon\",\"en\":\"Configuration\"},\"path\":\"/training/configuration\"},{\"label\":{\"et\":\"Vormid\",\"en\":\"Forms\"},\"path\":\"/training/forms\"},{\"label\":{\"et\":\"Mälukohad\",\"en\":\"Slots\"},\"path\":\"/training/slots\"},{\"hidden\":true,\"label\":{\"et\":\"Automatic Teenused\",\"en\":\"Automatic Services\"},\"path\":\"/auto-services\"}]},{\"label\":{\"et\":\"Ajaloolised vestlused\",\"en\":\"Historical conversations\"},\"path\":\"/history\",\"children\":[{\"label\":{\"et\":\"Ajalugu\",\"en\":\"History\"},\"path\":\"/history/history\"},{\"hidden\":true,\"label\":{\"et\":\"Pöördumised\",\"en\":\"Appeals\"},\"path\":\"/history/appeal\"}]},{\"label\":{\"et\":\"Mudelipank ja analüütika\",\"en\":\"Modelbank and analytics\"},\"path\":\"/analytics\",\"children\":[{\"label\":{\"et\":\"Teemade ülevaade\",\"en\":\"Overview of topics\"},\"path\":\"/analytics/overview\"},{\"label\":{\"et\":\"Mudelite võrdlus\",\"en\":\"Comparison of models\"},\"path\":\"/analytics/models\"},{\"hidden\":true,\"label\":{\"et\":\"Testlood\",\"en\":\"testTracks\"},\"path\":\"/analytics/testcases\"}]},{\"label\":{\"et\":\"Treeni uus mudel\",\"en\":\"Train new model\"},\"path\":\"/train-new-model\"}]},{\"id\":\"analytics\",\"label\":{\"et\":\"Analüütika\",\"en\":\"Analytics\"},\"path\":\"/analytics\",\"children\":[{\"label\":{\"et\":\"Ülevaade\",\"en\":\"Overview\"},\"path\":\"/overview\"},{\"label\":{\"et\":\"Vestlused\",\"en\":\"Chats\"},\"path\":\"/chats\"},{\"label\":{\"et\":\"Tagasiside\",\"en\":\"Feedback\"},\"path\":\"/feedback\"},{\"label\":{\"et\":\"Nõustajad\",\"en\":\"Advisors\"},\"path\":\"/advisors\"},{\"label\":{\"et\":\"Avaandmed\",\"en\":\"Reports\"},\"path\":\"/reports\"}]},{\"id\":\"services\",\"hidden\":true,\"label\":{\"et\":\"Teenused\",\"en\":\"Services\"},\"path\":\"/services\",\"children\":[{\"label\":{\"et\":\"Ülevaade\",\"en\":\"Overview\"},\"path\":\"/overview\"},{\"label\":{\"et\":\"Uus teenus\",\"en\":\"New Service\"},\"path\":\"/newService\"},{\"label\":{\"et\":\"Automatic Teenused\",\"en\":\"Automatic Services\"},\"path\":\"/auto-services\"},{\"label\":{\"et\":\"Probleemsed teenused\",\"en\":\"Faulty Services\"},\"path\":\"/faultyServices\"}]},{\"id\":\"settings\",\"label\":{\"et\":\"Haldus\",\"en\":\"Administration\"},\"path\":\"/settings\",\"children\":[{\"label\":{\"et\":\"Kasutajad\",\"en\":\"Users\"},\"path\":\"/users\"},{\"label\":{\"et\":\"Vestlusbot\",\"en\":\"Chatbot\"},\"path\":\"/chatbot\",\"children\":[{\"label\":{\"et\":\"Seaded\",\"en\":\"Settings\"},\"path\":\"/chatbot/settings\"},{\"label\":{\"et\":\"Tervitussõnum\",\"en\":\"Welcome message\"},\"path\":\"/chatbot/welcome-message\"},{\"label\":{\"et\":\"Välimus ja käitumine\",\"en\":\"Appearance and behavior\"},\"path\":\"/chatbot/appearance\"},{\"label\":{\"et\":\"Erakorralised teated\",\"en\":\"Emergency notices\"},\"path\":\"/chatbot/emergency-notices\"}]},{\"label\":{\"et\":\"Asutuse tööaeg\",\"en\":\"Office opening hours\"},\"path\":\"/working-time\"},{\"label\":{\"et\":\"Sessiooni pikkus\",\"en\":\"Session length\"},\"path\":\"/session-length\"}]},{\"id\":\"monitoring\",\"hidden\":true,\"label\":{\"et\":\"Seire\",\"en\":\"Monitoring\"},\"path\":\"/monitoring\",\"children\":[{\"label\":{\"et\":\"Aktiivaeg\",\"en\":\"Working hours\"},\"path\":\"/uptime\"}]}]"
8181
```

0 commit comments

Comments
 (0)