Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1008935 // webChatBotLogsHTML

JavaX fragment (include)

static S webChatBotLogsHTML() {
  ret withDBLock(func -> S {
    new L<S> l;
    for (Conversation conv : sortByCalculatedFieldDesc(list Conversation(), func(Conversation c) { empty(c.msgs) ? c.created : last(c.msgs).time })) {
      LL<Msg> dialogs = reversed(unnull(conv.oldDialogs));
      l.add(webChatBotLogsHTML_formatDialog(str(conv.id + "/" + (l(dialogs)+1)), conv.msgs));
      int i = l(dialogs);
      for (L<Msg> msgs : dialogs)
        l.add(webChatBotLogsHTML_formatDialog(conv.id + "/" + (i--), msgs));
    }
    ret h3_htitle("Chat Logs") + ul(l, null, style := "margin-top: 1em");
  });
}

sS webChatBotLogsHTML_formatDialog(S id, L<Msg> msgs) {
  long startTime = collectMinLong(msgs, 'time);
  long endTime = collectMaxLong(msgs, 'time);
  new L<S> lc;
  for (Msg m : msgs)
    if (m.fromUser)
      lc.add("U: " + i(htmlencode(m.text)));
    else
      lc.add("B: " + htmlencode(m.text));
  S time1 = formatDateAndTime(startTime);
  S time2 = formatDateAndTime(endTime);
  time2 = shortenEndTime(time2, time1);
  ret id + " [" + htmlencode(time1) + " - " + htmlencode(time2) + "]" + ul(lc);
}

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: 473 / 533
Version history: 11 change(s)
Referenced in: [show references]