2023-07-14 19:06:57 +03:00
|
|
|
:: summarize: utilities for summarizing groups/chat state in various ways
|
|
|
|
::
|
2023-07-24 22:44:06 +03:00
|
|
|
/- chat, groups
|
2023-07-14 19:06:57 +03:00
|
|
|
::
|
|
|
|
|_ [our=@p now=@da]
|
2023-07-18 23:50:47 +03:00
|
|
|
:: +range: period of time to summarize over
|
|
|
|
:: +limit: max amount of msgs to count per channel
|
|
|
|
::
|
|
|
|
++ range ~d7
|
|
|
|
++ limit 9.999
|
|
|
|
::
|
2023-07-14 19:06:57 +03:00
|
|
|
++ scry-path
|
|
|
|
|= [=term =spur]
|
|
|
|
[(scot %p our) term (scot %da now) spur]
|
|
|
|
::
|
|
|
|
++ summarize-activity
|
|
|
|
^- $: sent=@ud
|
|
|
|
received=@ud
|
|
|
|
most-sent-group=@t
|
|
|
|
==
|
|
|
|
=- :+ s r
|
|
|
|
=/ g=flag:chat
|
|
|
|
=< -
|
|
|
|
::TODO crashes if no groups
|
|
|
|
%+ snag 0
|
|
|
|
%+ sort ~(tap by g)
|
|
|
|
|=([[* a=@ud] [* b=@ud]] (gth a b))
|
|
|
|
=< title.meta
|
|
|
|
.^ group:groups
|
|
|
|
%gx
|
|
|
|
(scry-path %groups /groups/(scot %p p.g)/[q.g]/group)
|
|
|
|
==
|
|
|
|
%+ roll
|
|
|
|
%~ tap in
|
|
|
|
.^ (map flag:chat chat:chat)
|
|
|
|
%gx
|
|
|
|
(scry-path %chat /chats/chats)
|
|
|
|
==
|
|
|
|
=* onn ((on time writ:chat) lte)
|
|
|
|
|= [[c=flag:chat chat:chat] g=(map flag:chat @ud) s=@ud r=@ud]
|
|
|
|
=+ .^ log=((mop time writ:chat) lte)
|
|
|
|
%gx
|
|
|
|
%+ scry-path %chat
|
2023-07-18 23:50:47 +03:00
|
|
|
/chat/(scot %p p.c)/[q.c]/writs/newer/(scot %ud (sub now range))/(scot %ud limit)/chat-writs
|
2023-07-14 19:06:57 +03:00
|
|
|
==
|
|
|
|
:- %+ ~(put by g) group.perm
|
|
|
|
(add (~(gut by g) group.perm 0) (wyt:onn log))
|
|
|
|
%+ roll (tap:onn log)
|
|
|
|
|= [[time writ:chat] s=_s r=_r]
|
|
|
|
?:(=(our author) [+(s) r] [s +(r)])
|
|
|
|
::
|
|
|
|
++ summarize-inactivity
|
|
|
|
^- $: unread-dms=@ud :: unread dm count
|
|
|
|
unread-etc=@ud :: unread chats count
|
|
|
|
top-group=@t :: most active group
|
|
|
|
top-channel=@t :: most active channel
|
|
|
|
==
|
|
|
|
=+ .^ =briefs:chat
|
|
|
|
%gx
|
|
|
|
(scry-path %chat /briefs/chat-briefs)
|
|
|
|
==
|
|
|
|
:: accumulate unread counts
|
|
|
|
::
|
|
|
|
=/ [dum=@ud duc=@ud]
|
|
|
|
%- ~(rep by briefs)
|
|
|
|
|= [[w=whom:chat brief:briefs:chat] n=@ud m=@ud]
|
|
|
|
?: ?=(%flag -.w) [n (add m count)]
|
|
|
|
[(add n count) m]
|
|
|
|
:+ dum duc
|
|
|
|
:: gather all chat channels & their groups & unread counts
|
|
|
|
::
|
|
|
|
=/ faz=(list [g=flag:chat c=flag:chat n=@ud])
|
|
|
|
%+ turn
|
|
|
|
%~ tap in
|
|
|
|
.^ (map flag:chat chat:chat)
|
|
|
|
%gx
|
|
|
|
(scry-path %chat /chats/chats)
|
|
|
|
==
|
|
|
|
|= [c=flag:chat chat:chat]
|
|
|
|
:+ group.perm c
|
|
|
|
count:(~(gut by briefs) flag+c *brief:briefs:chat)
|
|
|
|
=. faz (sort faz |=([[* * a=@ud] [* * b=@ud]] (gth a b)))
|
|
|
|
:: get display titles of most active channel and its group
|
|
|
|
::
|
|
|
|
::NOTE in rare cases, we might not know of the existence of the associated
|
|
|
|
:: group. simply skip past it and try the next one...
|
|
|
|
=+ .^ =groups:groups
|
|
|
|
%gx
|
|
|
|
(scry-path %groups /groups/groups)
|
|
|
|
==
|
|
|
|
|-
|
|
|
|
?~ faz ['???' '???'] ::TODO better copy
|
2023-07-28 21:43:13 +03:00
|
|
|
~| i.faz
|
2023-07-14 19:06:57 +03:00
|
|
|
?. (~(has by groups) g.i.faz)
|
|
|
|
$(faz t.faz)
|
|
|
|
=/ =group:^groups (~(got by groups) g.i.faz)
|
2023-07-28 21:43:13 +03:00
|
|
|
?~ chat=(~(get by channels.group) %chat c.i.faz)
|
|
|
|
$(faz t.faz)
|
|
|
|
[title.meta.group title.meta.u.chat]
|
2023-07-14 19:06:57 +03:00
|
|
|
--
|