shrub/pkg/arvo/lib/hark/store.hoon

320 lines
6.9 KiB
Plaintext
Raw Normal View History

2020-10-27 08:04:39 +03:00
/- sur=hark-store, post
/+ resource, graph-store, group-store
2020-10-27 08:04:39 +03:00
^?
=< [. sur]
=, sur
|%
++ dejs
=, dejs:format
|%
++ index
%- of
:~ graph+graph-index
group+group-index
==
::
++ group-index
%- ot
:~ group+dejs-path:resource
description+so
==
::
++ graph-index
%- ot
:~ group+dejs-path:resource
graph+dejs-path:resource
module+so
description+so
index+(su ;~(pfix fas (more fas dem)))
2020-10-27 08:04:39 +03:00
==
2020-12-16 07:22:23 +03:00
::
++ stats-index
%- of
:~ graph+graph-stats-index
2020-12-16 10:37:10 +03:00
group+dejs-path:resource
2020-12-16 07:22:23 +03:00
==
++ graph-stats-index
%- ot
2020-12-16 10:37:10 +03:00
:~ graph+dejs-path:resource
index+graph-store-index
2020-12-16 07:22:23 +03:00
==
2020-10-27 08:04:39 +03:00
:: parse date as @ud
:: TODO: move to zuse
++ sd
|= jon=json
^- @da
?> ?=(%s -.jon)
`@da`(rash p.jon dem:ag)
::
++ notif-ref
^- $-(json [@da ^index])
%- ot
:~ time+sd
index+index
==
2020-12-16 10:37:10 +03:00
++ graph-store-index
2020-12-16 07:22:23 +03:00
(su ;~(pfix fas (more fas dem)))
2020-10-27 08:04:39 +03:00
::
++ add
|= jon=json
[*^index *notification]
::
++ read-graph-index
%- ot
2020-12-16 07:22:23 +03:00
:~ index+stats-index
2020-12-16 10:37:10 +03:00
target+graph-store-index
==
::
2020-10-27 08:04:39 +03:00
++ action
^- $-(json ^action)
%- of
:~ seen+ul
archive+notif-ref
unread-note+notif-ref
read-note+notif-ref
add-note+add
2020-10-27 08:04:39 +03:00
set-dnd+bo
2020-12-16 07:22:23 +03:00
read-count+stats-index
read-each+read-graph-index
2020-10-27 08:04:39 +03:00
==
--
::
++ enjs
=, enjs:format
|%
++ update
|= upd=^update
^- json
|^
%+ frond -.upd
?+ -.upd a+~
2020-10-28 08:52:59 +03:00
%added (added +.upd)
2020-10-27 08:04:39 +03:00
%timebox (timebox +.upd)
%set-dnd b+dnd.upd
%count (numb count.upd)
%more (more +.upd)
2020-12-01 08:46:28 +03:00
%read-each (read-each +.upd)
2020-12-16 07:22:23 +03:00
%read-count (stats-index +.upd)
%unread-each (unread-each +.upd)
2020-12-01 08:46:28 +03:00
%unread-count (unread-count +.upd)
2020-12-17 09:10:26 +03:00
%remove-graph s+(enjs-path:resource +.upd)
%seen-index (seen-index +.upd)
%unreads (unreads +.upd)
2020-11-10 06:32:48 +03:00
::
?(%archive %read-note %unread-note)
2020-10-27 08:04:39 +03:00
(notif-ref +.upd)
==
::
2020-12-16 07:22:23 +03:00
++ stats-index
|= s=^stats-index
%+ frond -.s
|^
?- -.s
%graph (graph-stats-index +.s)
2020-12-16 10:37:10 +03:00
%group s+(enjs-path:resource +.s)
2020-12-16 07:22:23 +03:00
==
::
++ graph-stats-index
|= [graph=resource =index:graph-store]
%- pairs
2020-12-16 10:37:10 +03:00
:~ graph+s+(enjs-path:resource graph)
2020-12-16 07:22:23 +03:00
index+(index:enjs:graph-store index)
==
--
::
2020-11-16 05:22:42 +03:00
++ unreads
2020-12-16 07:22:23 +03:00
|= l=(list [^stats-index ^stats])
2020-11-12 04:31:33 +03:00
^- json
2020-11-16 05:22:42 +03:00
:- %a
^- (list json)
%+ turn l
2020-12-16 07:22:23 +03:00
|= [idx=^stats-index s=^stats]
2020-11-12 04:31:33 +03:00
%- pairs
2020-12-16 07:22:23 +03:00
:~ stats+(stats s)
index+(stats-index idx)
2020-11-16 05:22:42 +03:00
==
2020-11-12 04:31:33 +03:00
::
++ unread
|= =^unreads
%+ frond
-.unreads
?- -.unreads
%each a+(turn ~(tap by indices.unreads) index:enjs:graph-store)
2020-12-01 08:46:28 +03:00
::
%count
(numb num.unreads)
==
::
2020-12-16 07:22:23 +03:00
++ stats
|= s=^stats
^- json
%- pairs
2020-12-16 07:22:23 +03:00
:~ unreads+(unread unreads.s)
notifications+(numb notifications.s)
last+(time last-seen.s)
==
2020-10-28 08:52:59 +03:00
++ added
|= [tim=@da idx=^index not=^notification]
^- json
%- pairs
:~ time+s+(scot %ud tim)
index+(index idx)
notification+(notification not)
==
::
2020-10-27 08:04:39 +03:00
++ notif-ref
|= [tim=@da idx=^index]
^- json
%- pairs
:~ time+s+(scot %ud tim)
index+(index idx)
==
++ seen-index
2020-12-16 07:22:23 +03:00
|= [tim=@da idx=^stats-index]
^- json
%- pairs
:~ time+(time tim)
2020-12-16 07:22:23 +03:00
index+(stats-index idx)
==
2020-10-27 08:04:39 +03:00
::
++ more
|= upds=(list ^update)
^- json
a+(turn upds update)
::
++ index
|= =^index
%+ frond -.index
|^
?- -.index
%graph (graph-index +.index)
%group (group-index +.index)
==
::
++ graph-index
|= $: group=resource
graph=resource
module=@t
description=@t
idx=index:graph-store
==
2020-10-27 08:04:39 +03:00
^- json
%- pairs
:~ group+s+(enjs-path:resource group)
graph+s+(enjs-path:resource graph)
module+s+module
description+s+description
index+(index:enjs:graph-store idx)
2020-10-27 08:04:39 +03:00
==
::
++ group-index
|= [group=resource description=@t]
^- json
%- pairs
:~ group+s+(enjs-path:resource group)
description+s+description
==
--
::
++ notification
|= ^notification
^- json
%- pairs
:~ time+(time date)
read+b+read
contents+(^contents contents)
==
::
++ contents
|= =^contents
^- json
%+ frond -.contents
|^
?- -.contents
%graph (graph-contents +.contents)
%group (group-contents +.contents)
==
::
++ graph-contents
|= =(list post:post)
^- json
:- %a
(turn list post:enjs:graph-store)
::
++ group-contents
|= =(list ^group-contents)
^- json
:- %a
%+ murn list
|= =^group-contents
?. ?=(?(%add-members %remove-members) -.group-contents)
~
`(update:enjs:group-store group-contents)
--
::
++ indexed-notification
|= [=^index =^notification]
%- pairs
:~ index+(^index index)
notification+(^notification notification)
==
::
++ timebox
|= [tim=@da arch=? l=(list [^index ^notification])]
^- json
%- pairs
:~ time+s+(scot %ud tim)
archive+b+arch
:- %notifications
^- json
:- %a
%+ turn l
|= [=^index =^notification]
^- json
(indexed-notification index notification)
==
::
2020-12-01 08:46:28 +03:00
++ read-each
2020-12-16 07:22:23 +03:00
|= [s=^stats-index target=index:graph-store]
%- pairs
2020-12-16 07:22:23 +03:00
:~ index+(stats-index s)
target+(index:enjs:graph-store target)
==
::
++ unread-each
2020-12-16 07:22:23 +03:00
|= [s=^stats-index target=index:graph-store tim=@da]
%- pairs
2020-12-16 07:22:23 +03:00
:~ index+(stats-index s)
target+(index:enjs:graph-store target)
last+(time tim)
==
::
2020-12-01 08:46:28 +03:00
++ unread-count
2020-12-16 07:22:23 +03:00
|= [s=^stats-index tim=@da]
%- pairs
2020-12-16 07:22:23 +03:00
:~ index+(stats-index s)
last+(time tim)
==
2020-10-27 08:04:39 +03:00
--
--
2020-12-16 07:22:23 +03:00
::
++ to-stats-index
|= =index
^- stats-index
?- -.index
%graph [%graph graph.index index.index]
%group [%group group.index]
==
++ stats-index-is-index
|= [=stats-index =index]
?- -.index
%graph
?. ?=(%graph -.stats-index) %.n
=([graph index]:index [graph index]:stats-index)
::
%group
?. ?=(%group -.stats-index) %.n
=(group:index group:stats-index)
==
2020-10-27 08:04:39 +03:00
--