2020-11-24 05:20:44 +03:00
|
|
|
:: hark-store: notifications and unread counts [landscape]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
:: hark-store can store unread counts differently, depending on the
|
|
|
|
:: resource.
|
|
|
|
:: - last seen. This way, hark-store simply stores an index into
|
|
|
|
:: graph-store, which represents the last "seen" item, useful for
|
|
|
|
:: high-volume applications which are intrinsically time-ordered. i.e.
|
|
|
|
:: chats, comments
|
|
|
|
:: - each. Hark-store will store an index for each item that is unread.
|
|
|
|
:: Usefull for non-linear, low-volume applications, i.e. blogs,
|
|
|
|
:: collections
|
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
/- store=hark-store
|
|
|
|
/+ verb, dbug, default-agent, re=hark-unreads, agentio
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
::
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %hark-store-top ..part ~
|
2020-10-21 08:54:59 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
2021-09-06 06:22:25 +03:00
|
|
|
$% state-2
|
2021-01-11 02:51:53 +03:00
|
|
|
state-3
|
2021-02-04 04:39:59 +03:00
|
|
|
state-4
|
2021-03-02 05:43:51 +03:00
|
|
|
state-5
|
2021-03-18 10:02:39 +03:00
|
|
|
state-6
|
2021-04-28 07:57:53 +03:00
|
|
|
state-7
|
2021-09-06 06:22:25 +03:00
|
|
|
state-8
|
2021-10-21 21:51:55 +03:00
|
|
|
state-9
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
|
|
|
::
|
2021-03-18 10:02:39 +03:00
|
|
|
+$ base-state
|
2021-09-06 06:22:25 +03:00
|
|
|
$: places=(map place:store stats:store)
|
2021-09-17 03:44:35 +03:00
|
|
|
seen=timebox:store
|
|
|
|
unseen=timebox:store
|
|
|
|
=archive:store
|
|
|
|
half-open=(map bin:store @da)
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
2020-12-16 07:22:23 +03:00
|
|
|
::
|
2021-01-11 02:51:53 +03:00
|
|
|
+$ state-2
|
2021-09-06 06:22:25 +03:00
|
|
|
[%2 *]
|
2021-01-11 02:51:53 +03:00
|
|
|
::
|
|
|
|
+$ state-3
|
2021-09-06 06:22:25 +03:00
|
|
|
[%3 *]
|
2021-02-04 04:39:59 +03:00
|
|
|
::
|
|
|
|
+$ state-4
|
2021-09-06 06:22:25 +03:00
|
|
|
[%4 *]
|
2021-01-11 02:51:53 +03:00
|
|
|
::
|
2021-03-02 05:43:51 +03:00
|
|
|
+$ state-5
|
2021-09-06 06:22:25 +03:00
|
|
|
[%5 *]
|
2021-03-18 10:02:39 +03:00
|
|
|
::
|
|
|
|
+$ state-6
|
2021-09-06 06:22:25 +03:00
|
|
|
[%6 *]
|
2021-04-28 07:57:53 +03:00
|
|
|
::
|
|
|
|
+$ state-7
|
2021-09-06 06:22:25 +03:00
|
|
|
[%7 *]
|
2021-03-02 05:43:51 +03:00
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
+$ state-8
|
|
|
|
[%8 base-state]
|
|
|
|
::
|
2021-10-21 21:51:55 +03:00
|
|
|
+$ state-9
|
|
|
|
[%9 base-state]
|
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
::
|
|
|
|
+$ cached-state
|
2021-09-17 03:44:35 +03:00
|
|
|
$: by-place=(jug place:store [=lid:store =path])
|
2021-09-06 06:22:25 +03:00
|
|
|
~
|
|
|
|
==
|
|
|
|
+$ inflated-state
|
2021-10-21 21:51:55 +03:00
|
|
|
[state-9 cached-state]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-16 06:52:45 +03:00
|
|
|
++ orm ((ordered-map @da timebox:store) gth)
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
=| inflated-state
|
2020-10-21 08:54:59 +03:00
|
|
|
=* state -
|
|
|
|
::
|
|
|
|
=<
|
2021-09-29 07:48:27 +03:00
|
|
|
%+ verb |
|
2020-10-21 08:54:59 +03:00
|
|
|
%- agent:dbug
|
|
|
|
^- agent:gall
|
|
|
|
~% %hark-store-agent ..card ~
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
ha ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2021-09-10 06:45:23 +03:00
|
|
|
io ~(. agentio bowl)
|
|
|
|
pass pass:io
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
++ on-init
|
2021-09-06 06:22:25 +03:00
|
|
|
`this
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
++ on-save !>(-.state)
|
2020-10-21 08:54:59 +03:00
|
|
|
++ on-load
|
2020-10-27 08:07:13 +03:00
|
|
|
|= =old=vase
|
|
|
|
=/ old
|
2020-11-24 05:20:44 +03:00
|
|
|
!<(versioned-state old-vase)
|
|
|
|
=| cards=(list card)
|
2021-10-21 21:51:55 +03:00
|
|
|
|- ^- (quip card _this)
|
|
|
|
?+ -.old
|
|
|
|
:: pre-dist migration
|
|
|
|
:_ this
|
|
|
|
(poke-our:pass %hark-graph-hook hark-graph-migrate+old-vase)^~
|
|
|
|
::
|
|
|
|
%9
|
2021-09-06 06:22:25 +03:00
|
|
|
=. -.state old
|
2021-10-13 19:54:32 +03:00
|
|
|
=. +.state inflate:ha
|
2021-09-06 06:22:25 +03:00
|
|
|
:_(this (flop cards))
|
2021-09-10 06:45:23 +03:00
|
|
|
::
|
2021-10-21 21:51:55 +03:00
|
|
|
%8
|
|
|
|
$(-.old %9, archive.old *archive:store)
|
|
|
|
==
|
2020-10-27 08:07:13 +03:00
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
2020-11-24 05:20:44 +03:00
|
|
|
?> (team:title [src our]:bowl)
|
2020-10-27 08:07:13 +03:00
|
|
|
|^
|
|
|
|
?+ path (on-watch:def path)
|
2021-09-06 06:22:25 +03:00
|
|
|
[%notes ~] `this
|
2020-10-27 08:07:13 +03:00
|
|
|
::
|
|
|
|
[%updates ~]
|
|
|
|
:_ this
|
|
|
|
[%give %fact ~ hark-update+!>(initial-updates)]~
|
2021-09-06 06:22:25 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
==
|
2020-11-10 06:32:48 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
++ initial-updates
|
|
|
|
^- update:store
|
|
|
|
:- %more
|
|
|
|
^- (list update:store)
|
2021-09-17 03:44:35 +03:00
|
|
|
:~ [%timebox unseen+~ ~(val by unseen)]
|
|
|
|
[%timebox seen+~ ~(val by seen)]
|
2021-09-06 06:22:25 +03:00
|
|
|
[%all-stats places]
|
2021-02-22 03:47:38 +03:00
|
|
|
==
|
2020-10-27 08:07:13 +03:00
|
|
|
--
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2022-03-23 03:05:24 +03:00
|
|
|
++ on-peek
|
|
|
|
~/ %hark-store-peek
|
2020-10-27 08:07:13 +03:00
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
|
|
|
::
|
2022-03-23 03:05:24 +03:00
|
|
|
[%x %recent %inbox @ @ ~]
|
|
|
|
=/ date=@da
|
|
|
|
(slav %ud i.t.t.t.path)
|
|
|
|
=/ length=@ud
|
|
|
|
(slav %ud i.t.t.t.t.path)
|
|
|
|
:^ ~ ~ %hark-update
|
|
|
|
!> ^- update:store
|
|
|
|
:- %more
|
|
|
|
%+ turn (tab:orm archive `date length)
|
|
|
|
|= [time=@da =timebox:store]
|
|
|
|
^- update:store
|
|
|
|
[%timebox archive+time ~(val by timebox)]
|
|
|
|
::
|
|
|
|
[%x %all-stats ~]
|
|
|
|
:^ ~ ~ %hark-update
|
|
|
|
!> ^- update:store
|
|
|
|
:- %more
|
|
|
|
^- (list update:store)
|
|
|
|
:~ [%all-stats places]
|
|
|
|
==
|
2020-10-27 08:07:13 +03:00
|
|
|
==
|
2020-11-10 06:32:48 +03:00
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ on-poke
|
|
|
|
~/ %hark-store-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%hark-action (hark-action !<(action:store vase))
|
2021-01-11 02:51:53 +03:00
|
|
|
%noun (poke-noun !<(* vase))
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2021-01-11 02:51:53 +03:00
|
|
|
++ poke-noun
|
|
|
|
|= val=*
|
|
|
|
?+ val ~|(%bad-noun-poke !!)
|
|
|
|
%print ~&(+.state [~ state])
|
2021-09-17 03:44:35 +03:00
|
|
|
%clear [~ state(. *inflated-state)]
|
2021-10-25 19:51:52 +03:00
|
|
|
%sane
|
2021-10-13 19:54:32 +03:00
|
|
|
~& +.state
|
|
|
|
~& inflate
|
|
|
|
?>(=(+.state inflate) `state)
|
2021-01-11 02:51:53 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ poke-us
|
|
|
|
|= =action:store
|
|
|
|
^- card
|
|
|
|
[%pass / %agent [our dap]:bowl %poke hark-action+!>(action)]
|
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ hark-action
|
|
|
|
|= =action:store
|
|
|
|
^- (quip card _state)
|
2021-09-06 06:22:25 +03:00
|
|
|
abet:(abed:poke-engine:ha action)
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?. ?=([%autoseen ~] wire)
|
|
|
|
(on-arvo:def wire sign-arvo)
|
2021-05-17 06:35:00 +03:00
|
|
|
`this
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* met ~(. metadata bowl)
|
2021-09-06 06:22:25 +03:00
|
|
|
io ~(. agentio bowl)
|
|
|
|
pass pass:io
|
2020-12-15 08:38:56 +03:00
|
|
|
++ poke-engine
|
2021-09-06 06:22:25 +03:00
|
|
|
|_ [out=(list update:store) cards=(list card)]
|
2020-12-15 08:38:56 +03:00
|
|
|
++ poke-core .
|
|
|
|
::
|
|
|
|
++ abed
|
2021-09-06 06:22:25 +03:00
|
|
|
|= in=action:store
|
2021-09-17 03:44:35 +03:00
|
|
|
^+ poke-core
|
2021-01-23 00:00:20 +03:00
|
|
|
?- -.in
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
%add-note (add-note +.in)
|
2021-09-06 06:22:25 +03:00
|
|
|
%del-place (del-place +.in)
|
2020-12-15 08:38:56 +03:00
|
|
|
%archive (do-archive +.in)
|
|
|
|
::
|
|
|
|
%unread-count (unread-count +.in)
|
|
|
|
%read-count (read-count +.in)
|
|
|
|
::
|
|
|
|
%read-each (read-each +.in)
|
|
|
|
%unread-each (unread-each +.in)
|
|
|
|
::
|
|
|
|
%read-note (read-note +.in)
|
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
%saw-place (saw-place +.in)
|
2021-05-25 06:38:09 +03:00
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
%opened opened
|
2021-09-06 06:22:25 +03:00
|
|
|
%archive-all archive-all
|
2021-01-23 00:00:20 +03:00
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
==
|
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
++ abet
|
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
|
|
|
%+ snoc (flop cards)
|
|
|
|
[%give %fact ~[/updates] %hark-update !>([%more (flop out)])]
|
|
|
|
::
|
|
|
|
++ give |=(=update:store poke-core(out [update out]))
|
|
|
|
++ emit |=(=card poke-core(cards [card cards]))
|
|
|
|
::
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
:: +| %note
|
|
|
|
::
|
|
|
|
:: notification tracking
|
|
|
|
++ put-notifs
|
|
|
|
|= [time=@da =timebox:store]
|
2021-09-17 03:44:35 +03:00
|
|
|
poke-core(archive (put:orm archive time timebox))
|
|
|
|
::
|
|
|
|
++ put-lid
|
|
|
|
|= [=lid:store =bin:store =notification:store]
|
|
|
|
^+ poke-core
|
|
|
|
=. by-place (~(put ju by-place) place.bin [lid path.bin])
|
|
|
|
?- -.lid
|
|
|
|
%seen
|
|
|
|
poke-core(seen (~(put by seen) bin notification))
|
|
|
|
::
|
|
|
|
%unseen
|
|
|
|
poke-core(unseen (~(put by unseen) bin notification))
|
|
|
|
::
|
|
|
|
%archive
|
|
|
|
poke-core(archive (~(put re archive) time.lid bin notification))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ del-lid
|
|
|
|
|= [=lid:store =bin:store]
|
|
|
|
=. by-place (~(del ju by-place) place.bin [lid path.bin])
|
|
|
|
?- -.lid
|
|
|
|
%seen poke-core(seen (~(del by seen) bin))
|
|
|
|
%unseen poke-core(unseen (~(del by unseen) bin))
|
|
|
|
%archive poke-core(archive (~(del re archive) time.lid bin))
|
|
|
|
==
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ add-note
|
2021-09-06 06:22:25 +03:00
|
|
|
|= [=bin:store =body:store]
|
2020-12-15 08:38:56 +03:00
|
|
|
^+ poke-core
|
2021-09-06 06:22:25 +03:00
|
|
|
=. poke-core
|
|
|
|
(emit (fact:io hark-update+!>([%add-note bin body]) /notes ~))
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ existing-notif
|
2021-09-17 03:44:35 +03:00
|
|
|
(~(gut by unseen) bin *notification:store)
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ new=notification:store
|
2021-09-17 03:44:35 +03:00
|
|
|
[now.bowl bin [body body.existing-notif]]
|
2021-10-25 19:51:52 +03:00
|
|
|
=. poke-core
|
|
|
|
(put-lid unseen/~ bin new)
|
2021-09-06 06:22:25 +03:00
|
|
|
(give %added new)
|
|
|
|
::
|
|
|
|
++ del-place
|
|
|
|
|= =place:store
|
2021-09-17 03:44:35 +03:00
|
|
|
=. poke-core (give %del-place place)
|
|
|
|
=/ notes=(list [=lid:store =path])
|
2021-09-06 06:22:25 +03:00
|
|
|
~(tap in (~(get ju by-place) place))
|
|
|
|
|- ^+ poke-core
|
|
|
|
?~ notes poke-core
|
2021-09-17 03:44:35 +03:00
|
|
|
=, i.notes
|
|
|
|
=. poke-core
|
|
|
|
(del-lid lid path place)
|
|
|
|
$(notes t.notes)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ do-archive
|
2021-09-17 03:44:35 +03:00
|
|
|
|= [=lid:store =bin:store]
|
2020-12-15 08:38:56 +03:00
|
|
|
^+ poke-core
|
2021-09-17 03:44:35 +03:00
|
|
|
~| %already-archived
|
|
|
|
?< ?=(%time -.lid)
|
|
|
|
~| %non-existent
|
|
|
|
=/ =notification:store (need (get-lid lid bin))
|
|
|
|
=. poke-core (del-lid lid bin)
|
|
|
|
=. poke-core (put-lid archive+now.bowl bin notification)
|
|
|
|
(give %archived now.bowl lid notification)
|
2021-05-17 06:35:00 +03:00
|
|
|
::
|
|
|
|
++ read-note
|
2021-09-06 06:22:25 +03:00
|
|
|
|= =bin:store
|
2021-05-17 06:35:00 +03:00
|
|
|
=/ =notification:store
|
2021-09-17 03:44:35 +03:00
|
|
|
(~(got by unseen) bin)
|
2021-10-25 19:51:52 +03:00
|
|
|
=. poke-core
|
|
|
|
(del-lid unseen/~ bin)
|
2021-05-17 06:35:00 +03:00
|
|
|
=/ =time
|
2021-09-06 06:22:25 +03:00
|
|
|
(fall timebox:(gut-place place.bin) now.bowl)
|
|
|
|
=. date.notification time
|
2021-10-25 19:51:52 +03:00
|
|
|
=. poke-core
|
|
|
|
(put-lid archive/time bin notification)
|
2021-09-06 06:22:25 +03:00
|
|
|
(give %note-read time bin)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
::
|
|
|
|
:: +| %each
|
|
|
|
::
|
|
|
|
:: each unread tracking
|
|
|
|
::
|
|
|
|
++ unread-each
|
2021-09-06 06:22:25 +03:00
|
|
|
|= [=place:store =path]
|
2021-09-17 03:44:35 +03:00
|
|
|
=. poke-core (saw-place place ~)
|
2021-09-06 06:22:25 +03:00
|
|
|
=. poke-core (give %unread-each place path)
|
|
|
|
%+ jub-place place
|
|
|
|
|=(=stats:store stats(each (~(put in each.stats) path)))
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ read-index-each
|
2021-09-06 06:22:25 +03:00
|
|
|
|= [=place:store =path]
|
|
|
|
%- read-bins
|
2020-12-15 08:38:56 +03:00
|
|
|
%+ skim
|
2021-09-17 03:44:35 +03:00
|
|
|
~(tap in ~(key by unseen))
|
2021-09-06 06:22:25 +03:00
|
|
|
|= =bin:store
|
|
|
|
?. =(place place.bin) %.n
|
2021-01-13 05:37:23 +03:00
|
|
|
=/ not=notification:store
|
2021-09-17 03:44:35 +03:00
|
|
|
(~(got by unseen) bin)
|
2021-09-06 06:22:25 +03:00
|
|
|
(lien body.not |=(=body:store =(binned.body path)))
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ read-each
|
2021-09-06 06:22:25 +03:00
|
|
|
|= [=place:store =path]
|
|
|
|
=. poke-core (read-index-each place path)
|
|
|
|
=. poke-core (give %read-each place path)
|
|
|
|
%+ jub-place place
|
|
|
|
|= =stats:store
|
|
|
|
%_ stats
|
|
|
|
timebox `now.bowl
|
|
|
|
each (~(del in each.stats) path)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ gut-place
|
|
|
|
|= =place:store
|
|
|
|
?: (~(has by places) place) (~(got by places) place)
|
|
|
|
=| def=stats:store
|
|
|
|
def(timebox ~, last now.bowl)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
++ jub-place
|
|
|
|
|= $: =place:store
|
|
|
|
f=$-(stats:store stats:store)
|
2020-12-15 08:38:56 +03:00
|
|
|
==
|
2021-09-06 06:22:25 +03:00
|
|
|
^+ poke-core
|
|
|
|
=/ =stats:store
|
|
|
|
(gut-place place)
|
|
|
|
poke-core(places (~(put by places) place (f stats)))
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ unread-count
|
2021-09-06 06:22:25 +03:00
|
|
|
|= [=place:store inc=? count=@ud]
|
|
|
|
=. poke-core
|
|
|
|
(give %unread-count place inc count)
|
2021-09-17 03:44:35 +03:00
|
|
|
=. poke-core (saw-place place ~)
|
2021-09-06 06:22:25 +03:00
|
|
|
=/ f
|
|
|
|
?: inc (cury add count)
|
|
|
|
(curr sub count)
|
|
|
|
%+ jub-place place
|
|
|
|
|= =stats:store
|
|
|
|
stats(count (f count.stats))
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
++ half-archive
|
|
|
|
|= =place:store
|
|
|
|
=/ bins=(list [=lid:store =path])
|
|
|
|
~(tap in (~(get ju by-place) place))
|
|
|
|
|-
|
|
|
|
?~ bins poke-core
|
|
|
|
=/ =bin:store
|
|
|
|
[path.i.bins place]
|
|
|
|
=* lid lid.i.bins
|
|
|
|
?: ?=(%archive -.lid)
|
|
|
|
$(bins t.bins)
|
|
|
|
=/ seen-place (~(get by seen) bin)
|
|
|
|
=/ n=(unit notification:store) (get-lid lid bin)
|
|
|
|
?~ n $(bins t.bins)
|
|
|
|
=* note u.n
|
|
|
|
=/ =time (~(gut by half-open) bin now.bowl)
|
|
|
|
=? half-open !(~(has by half-open) bin)
|
|
|
|
(~(put by half-open) bin now.bowl)
|
2021-10-13 19:54:32 +03:00
|
|
|
=/ existing (get-lid archive/time bin)
|
|
|
|
=/ new (merge-notification existing note)
|
2021-10-26 20:59:35 +03:00
|
|
|
=? half-open (lth 30 (lent body.new))
|
|
|
|
(~(del by half-open) bin)
|
2021-10-13 19:54:32 +03:00
|
|
|
=. poke-core
|
|
|
|
(put-lid archive/time bin new)
|
|
|
|
=. poke-core (del-lid lid bin)
|
2021-10-26 20:59:35 +03:00
|
|
|
=. poke-core (give %archived time lid (~(got re archive) time bin))
|
2021-09-17 03:44:35 +03:00
|
|
|
$(bins t.bins)
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ read-count
|
2021-09-06 06:22:25 +03:00
|
|
|
|= =place:store
|
|
|
|
=. poke-core (give %read-count place)
|
2021-09-17 03:44:35 +03:00
|
|
|
=. poke-core (half-archive place)
|
2021-09-06 06:22:25 +03:00
|
|
|
%+ jub-place place
|
|
|
|
|= =stats:store
|
|
|
|
stats(count 0, timebox `now.bowl)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
++ read-bins
|
|
|
|
|= bins=(list bin:store)
|
2020-12-16 10:37:10 +03:00
|
|
|
|-
|
2021-09-06 06:22:25 +03:00
|
|
|
?~ bins poke-core
|
2020-12-16 10:37:10 +03:00
|
|
|
=/ core
|
2021-09-06 06:22:25 +03:00
|
|
|
(read-note i.bins)
|
|
|
|
$(poke-core core, bins t.bins)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
++ saw-place
|
2021-09-10 06:45:23 +03:00
|
|
|
|= [=place:store time=(unit time)]
|
2021-09-17 03:44:35 +03:00
|
|
|
=. poke-core (give %saw-place place time)
|
2021-09-06 06:22:25 +03:00
|
|
|
%+ jub-place place
|
2021-09-10 06:45:23 +03:00
|
|
|
|=(=stats:store stats(last (fall time now.bowl)))
|
2020-12-17 09:10:26 +03:00
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
++ archive-seen
|
|
|
|
=/ seen=(list [=bin:store =notification:store]) ~(tap by seen)
|
|
|
|
poke-core
|
|
|
|
::
|
|
|
|
++ opened
|
2021-09-06 06:22:25 +03:00
|
|
|
=. poke-core (turn-places |=(=stats:store stats(timebox ~)))
|
2021-10-25 19:51:52 +03:00
|
|
|
=. poke-core (give %opened ~)
|
|
|
|
%+ roll ~(tap in ~(key by unseen))
|
|
|
|
|= [=bin:store out=_poke-core]
|
|
|
|
(opened-note:out bin)
|
|
|
|
::
|
|
|
|
++ opened-note
|
|
|
|
|= =bin:store
|
|
|
|
^+ poke-core
|
|
|
|
=/ old
|
|
|
|
(~(got by unseen) bin)
|
|
|
|
=. poke-core
|
|
|
|
(del-lid unseen/~ bin)
|
|
|
|
=/ se (~(get by seen) bin)
|
|
|
|
%^ put-lid seen/~ bin
|
|
|
|
(merge-notification se old)
|
2021-09-17 03:44:35 +03:00
|
|
|
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-09-06 06:22:25 +03:00
|
|
|
++ archive-all
|
2021-09-20 07:15:19 +03:00
|
|
|
|^
|
|
|
|
=. poke-core (archive-lid unseen/~ unseen)
|
|
|
|
(archive-lid seen/~ seen)
|
|
|
|
++ archive-lid
|
|
|
|
|= [=lid:store =timebox:store]
|
2021-09-20 07:51:01 +03:00
|
|
|
%+ roll ~(tap in ~(key by timebox))
|
2021-09-20 07:15:19 +03:00
|
|
|
|= [=bin:store out=_poke-core]
|
|
|
|
(do-archive:out lid bin)
|
|
|
|
--
|
2021-09-06 06:22:25 +03:00
|
|
|
::
|
|
|
|
++ turn-places
|
|
|
|
|= f=$-(stats:store stats:store)
|
|
|
|
=/ places ~(tap in ~(key by places))
|
|
|
|
|- ^+ poke-core
|
|
|
|
?~ places poke-core
|
|
|
|
=/ core=_poke-core (jub-place i.places f)
|
|
|
|
$(poke-core core, places t.places)
|
2020-12-15 08:38:56 +03:00
|
|
|
--
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2021-09-17 03:44:35 +03:00
|
|
|
++ get-lid
|
|
|
|
|= [=lid:store =bin:store]
|
2021-10-13 19:54:32 +03:00
|
|
|
=; =timebox:store
|
|
|
|
(~(get by timebox) bin)
|
|
|
|
?- -.lid
|
|
|
|
%unseen unseen
|
|
|
|
%seen seen
|
|
|
|
%archive (fall (get:orm archive time.lid) *timebox:store)
|
|
|
|
==
|
2021-09-17 03:44:35 +03:00
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ merge-notification
|
2020-12-15 08:38:56 +03:00
|
|
|
|= [existing=(unit notification:store) new=notification:store]
|
2020-10-21 08:54:59 +03:00
|
|
|
^- notification:store
|
2020-12-15 08:38:56 +03:00
|
|
|
?~ existing new
|
2021-09-17 03:44:35 +03:00
|
|
|
[(max date.u.existing date.new) bin.new (welp body.new body.u.existing)]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
:: +key-orm: +key:by for ordered maps
|
|
|
|
++ key-orm
|
2021-09-17 03:44:35 +03:00
|
|
|
|= =archive:store
|
2020-10-27 08:07:13 +03:00
|
|
|
^- (list @da)
|
2021-09-17 03:44:35 +03:00
|
|
|
(turn (tap:orm archive) |=([@da *] +<-))
|
2021-09-06 06:22:25 +03:00
|
|
|
::
|
2020-10-22 04:30:37 +03:00
|
|
|
:: +gut-orm: +gut:by for ordered maps
|
|
|
|
:: TODO: move to zuse.hoon
|
2020-10-21 08:54:59 +03:00
|
|
|
++ gut-orm
|
2021-09-17 03:44:35 +03:00
|
|
|
|= [=archive:store time=@da]
|
2020-10-21 08:54:59 +03:00
|
|
|
^- timebox:store
|
2021-09-17 03:44:35 +03:00
|
|
|
(fall (get:orm archive time) ~)
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
++ scry
|
|
|
|
|* [=mold p=path]
|
|
|
|
?> ?=(^ p)
|
|
|
|
?> ?=(^ t.p)
|
|
|
|
.^(mold i.p (scot %p our.bowl) i.t.p (scot %da now.bowl) t.t.p)
|
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ give
|
|
|
|
|= [paths=(list path) update=update:store]
|
|
|
|
^- (list card)
|
2020-10-27 08:07:13 +03:00
|
|
|
[%give %fact paths [%hark-update !>(update)]]~
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ tap-nonempty
|
2021-09-17 03:44:35 +03:00
|
|
|
|= =archive:store
|
2020-12-15 08:38:56 +03:00
|
|
|
^- (list [@da timebox:store])
|
2021-09-17 03:44:35 +03:00
|
|
|
%+ skim (tap:orm archive)
|
2020-12-15 08:38:56 +03:00
|
|
|
|=([@da =timebox:store] !=(~(wyt by timebox) 0))
|
2021-10-13 19:54:32 +03:00
|
|
|
::
|
|
|
|
++ inflate
|
|
|
|
=. by-place ~
|
|
|
|
=. by-place (index-timebox seen+~ seen by-place)
|
|
|
|
=. by-place (index-timebox unseen+~ unseen by-place)
|
|
|
|
=. by-place
|
|
|
|
%+ roll (tap:orm archive)
|
|
|
|
|= [[=time =timebox:store] out=_by-place]
|
|
|
|
(index-timebox archive/time timebox out)
|
|
|
|
+.state
|
|
|
|
::
|
|
|
|
++ index-timebox
|
|
|
|
|= [=lid:store =timebox:store out=_by-place]
|
|
|
|
^+ by-place
|
|
|
|
%+ roll ~(tap by timebox)
|
|
|
|
|= [[=bin:store =notification:store] out=_out]
|
|
|
|
(~(put ju out) place.bin [lid path.bin])
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|