1 | static S webChatBotLogsHTML() { |
2 | ret withDBLock(func -> S { |
3 | new L<S> l; |
4 | for (Conversation conv : sortByCalculatedFieldDesc(list Conversation(), func(Conversation c) { empty(c.msgs) ? c.created : last(c.msgs).time })) { |
5 | LL<Msg> dialogs = reversed(unnull(conv.oldDialogs)); |
6 | l.add(webChatBotLogsHTML_formatDialog(str(conv.id + "/" + (l(dialogs)+1)), conv.msgs)); |
7 | int i = l(dialogs); |
8 | for (L<Msg> msgs : dialogs) |
9 | l.add(webChatBotLogsHTML_formatDialog(conv.id + "/" + (i--), msgs)); |
10 | } |
11 | ret h3_htitle("Chat Logs") + ul(l, null, style := "margin-top: 1em"); |
12 | }); |
13 | } |
14 | |
15 | sS webChatBotLogsHTML_formatDialog(S id, L<Msg> msgs) { |
16 | long startTime = collectMinLong(msgs, 'time); |
17 | long endTime = collectMaxLong(msgs, 'time); |
18 | new L<S> lc; |
19 | for (Msg m : msgs) |
20 | if (m.fromUser) |
21 | lc.add("U: " + i(htmlencode(m.text))); |
22 | else |
23 | lc.add("B: " + htmlencode(m.text)); |
24 | S time1 = formatDateAndTime(startTime); |
25 | S time2 = formatDateAndTime(endTime); |
26 | time2 = shortenEndTime(time2, time1); |
27 | ret id + " [" + htmlencode(time1) + " - " + htmlencode(time2) + "]" + ul(lc); |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1008935 |
Snippet name: | webChatBotLogsHTML |
Eternal ID of this version: | #1008935/12 |
Text MD5: | f9f5d49ca82180d01c33e8354acf533c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-27 12:55:58 |
Source code size: | 1139 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 475 / 535 |
Version history: | 11 change(s) |
Referenced in: | [show references] |