Merge 2d50075bfb into release/next-js

This commit is contained in:
github-actions[bot] 2021-01-11 23:23:32 +00:00 committed by GitHub
commit 2b3b5289fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 324 additions and 41 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:632af0c484fc159ac58818b1510296319b45c73fc36eb9233e9270ae974d11e4
size 8547462
oid sha256:c512d0c3da3ce7f0ac25babcbbceba04a9e62975e9d92aec56ab00e1c2fc6224
size 8618963

View File

@ -5,7 +5,7 @@
/- glob
/+ default-agent, verb, dbug
|%
++ hash 0v5.hvt1e.ie7it.b7i7l.1r7jj.dn9ib
++ hash 0v5.sekq0.8skge.ekt62.i73ig.g5sep
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
+$ all-states
$% state-0

View File

@ -418,43 +418,81 @@
=/ =update-log:store (~(got by update-logs) resource)
=. update-log
(put:orm-log update-log time [%0 time [%remove-nodes resource indices]])
=/ [affected-indices=(set index:store) new-graph=graph:store]
(remove-indices resource graph (sort ~(tap in indices) by-lent))
::
:- (give [/updates]~ [%remove-nodes resource indices])
:- (give [/updates]~ [%remove-nodes resource (~(uni in indices) affected-indices)])
%_ state
update-logs (~(put by update-logs) resource update-log)
graphs
%+ ~(put by graphs)
resource
[(remove-indices resource graph ~(tap in indices)) mark]
[new-graph mark]
==
::
:: we always want to remove the deepest node first,
:: so we don't remove parents before children
++ by-lent
|* [a=(list) b=(list)]
^- ?
(gth (lent a) (lent b))
::
++ remove-indices
=| affected=(set index:store)
|= [=resource:store =graph:store indices=(list index:store)]
^- graph:store
?~ indices graph
^- [(set index:store) graph:store]
?~ indices [affected graph]
=^ new-affected graph
(remove-index graph i.indices)
%_ $
indices t.indices
graph (remove-index graph i.indices)
affected (~(uni in affected) new-affected)
==
::
++ get-descendants
|= =graph:store
=| indices=(list index:store)
=/ nodes (tap:orm:store graph)
%- ~(gas in *(set index:store))
|- =* tap-nodes $
^+ indices
%- zing
%+ turn nodes
|= [atom =node:store]
^- (list index:store)
%+ welp
index.post.node^~
?. ?=(%graph -.children.node)
~
%_ tap-nodes
nodes (tap:orm p.children.node)
==
::
++ remove-index
=| indices=(set index:store)
|= [=graph:store =index:store]
^- graph:store
?~ index graph
^- [(set index:store) graph:store]
?~ index [indices graph]
=* atom i.index
:: last index in list
::
?~ t.index
+:`[* graph:store]`(del:orm graph atom)
=^ rm-node graph (del:orm graph atom)
?~ rm-node `graph
?. ?=(%graph -.children.u.rm-node)
`graph
=/ new-indices
(get-descendants p.children.u.rm-node)
[(~(uni in indices) new-indices) graph]
=/ =node:store
~| "parent index does not exist to remove a node from!"
(need (get:orm graph atom))
~| "child index does not exist to remove a node from!"
?> ?=(%graph -.children.node)
%^ put:orm
graph
atom
node(p.children $(graph p.children.node, index t.index))
=^ new-indices p.children.node
$(graph p.children.node, index t.index)
:- (~(uni in indices) new-indices)
(put:orm graph atom node)
--
::
++ add-signatures
@ -868,6 +906,15 @@
|= [=atom =node:store]
^- [index:store node:store]
[~[atom] node]
::
[%x %node-exists @ @ @ *]
=/ =ship (slav %p i.t.t.path)
=/ =term i.t.t.t.path
=/ =index:store
(turn t.t.t.t.path (cury slav %ud))
=/ node=(unit node:store)
(get-node ship term index)
``noun+!>(?=(^ node))
::
[%x %node @ @ @ *]
=/ =ship (slav %p i.t.t.path)

View File

@ -167,16 +167,48 @@
::
?(%remove-graph %archive-graph)
(remove-graph resource.q.update)
::
%remove-nodes
(remove-nodes resource.q.update indices.q.update)
::
%add-nodes
=* rid resource.q.update
(check-nodes ~(val by nodes.q.update) rid)
==
:: this is awful, but notification kind should always switch
:: on the index, so hopefully doesn't matter
:: TODO: rethink this
++ remove-nodes
|= [rid=resource indices=(set index:graph-store)]
=/ to-remove
%- ~(gas by *(set [resource index:graph-store]))
(turn ~(tap in indices) (lead rid))
:_ state(watching (~(dif in watching) to-remove))
=/ =tube:clay
(get-conversion:ha rid)
%+ roll
~(tap in indices)
|= [=index:graph-store out=(list card)]
=| =indexed-post:graph-store
=. index.p.indexed-post index
=+ !<(u-notif-kind=(unit notif-kind) (tube !>(indexed-post)))
?~ u-notif-kind out
=* notif-kind u.u-notif-kind
=/ =stats-index:store
[%graph rid (scag parent-lent.notif-kind index)]
?. ?=(%each mode.notif-kind) out
:_ out
(poke-hark %read-each stats-index index)
::
++ poke-hark
|= =action:store
^- card
[%pass / %agent [our.bowl %hark-store] %poke hark-action+!>(action)]
::
++ remove-graph
|= rid=resource
=/ unwatched
%- ~(gas in *_watching)
%- ~(gas in *(set [resource index:graph-store]))
%+ skim ~(tap in watching)
|= [r=resource idx=index:graph-store]
=(r rid)
@ -246,6 +278,15 @@
::
|_ =bowl:gall
::
++ get-conversion
|= rid=resource
^- tube:clay
=+ %^ scry [our now]:bowl
,mark=(unit mark)
/gx/graph-store/graph-mark/(scot %p entity.rid)/[name.rid]/noun
?~ mark
|=(v=vase !>(~))
(scry-conversion [our now]:bowl q.byk.bowl u.mark)
::
++ give
|= [paths=(list path) =update:hook]
@ -288,13 +329,7 @@
update-core(rid r, updates upds, group grp, module mod)
::
++ get-conversion
^- tube:clay
=+ %^ scry [our now]:bowl
,mark=(unit mark)
/gx/graph-store/graph-mark/(scot %p entity.rid)/[name.rid]/noun
?~ mark
|=(v=vase !>(~))
(scry-conversion [our now]:bowl q.byk.bowl u.mark)
(^get-conversion rid)
::
++ abet
^- (quip card _state)

View File

@ -148,7 +148,9 @@
|= [=index:store =notification:store]
^- card
=- [%pass / %agent [our.bowl %hark-store] %poke -]
hark-action+!>([%add index notification])
:- %hark-action
!> ^- action:store
[%add-note index notification]
--
::
++ on-peek on-peek:def

View File

@ -21,13 +21,13 @@
$% state:state-zero:store
state:state-one:store
state-2
state-3
==
+$ unread-stats
[indices=(set index:graph-store) last=@da]
::
+$ state-2
$: %2
unreads-each=(jug stats-index:store index:graph-store)
+$ base-state
$: unreads-each=(jug stats-index:store index:graph-store)
unreads-count=(map stats-index:store @ud)
last-seen=(map stats-index:store @da)
=notifications:store
@ -36,8 +36,14 @@
dnd=_|
==
::
+$ state-2
[%2 base-state]
::
+$ state-3
[%3 base-state]
::
+$ inflated-state
$: state-2
$: state-3
cache
==
:: $cache: useful to have precalculated, but can be derived from state
@ -78,9 +84,19 @@
=| cards=(list card)
|^
?- -.old
%2
:- cards
%3
:- (flop cards)
this(-.state old, +.state (inflate-cache:ha old))
::
%2
%_ $
-.old %3
::
cards
:_ cards
[%pass / %agent [our dap]:bowl %poke noun+!>(%fix-dangling)]
==
::
%1
%_ $
@ -264,10 +280,41 @@
=^ cards state
?+ mark (on-poke:def mark vase)
%hark-action (hark-action !<(action:store vase))
%noun ~& +.state [~ state]
%noun (poke-noun !<(* vase))
==
[cards this]
::
++ poke-noun
|= val=*
?+ val ~|(%bad-noun-poke !!)
%fix-dangling fix-dangling
%print ~&(+.state [~ state])
==
::
++ fix-dangling
=/ graphs get-keys:gra
:_ state
%+ roll
~(tap by unreads-each)
|= $: [=stats-index:store indices=(set index:graph-store)]
out=(list card)
==
?. ?=(%graph -.stats-index) out
?. (~(has in graphs) graph.stats-index)
:_(out (poke-us %remove-graph graph.stats-index))
%+ welp out
%+ turn
%+ skip
~(tap in indices)
|= =index:graph-store
(check-node-existence:gra graph.stats-index index)
|=(=index:graph-store (poke-us %read-each stats-index index))
::
++ poke-us
|= =action:store
^- card
[%pass / %agent [our dap]:bowl %poke hark-action+!>(action)]
::
++ hark-action
|= =action:store
^- (quip card _state)
@ -338,6 +385,9 @@
|= [read=? time=@da =index:store]
poke-core(+.state (^upd-cache read time index))
::
++ rebuild-cache
poke-core(+.state (inflate-cache -.state))
::
++ put-notifs
|= [time=@da =timebox:store]
poke-core(notifications (put:orm notifications time timebox))
@ -380,17 +430,28 @@
(~(put by archive-box) index notification(read %.y))
(give %archive time index)
::
:: if we detect cache inconsistencies, wipe and rebuild
++ change-read-status
|= [time=@da =index:store read=?]
^+ poke-core
=. poke-core (upd-cache read time index)
%_ poke-core
notifications
%^ jub-orm notifications time
|= =timebox:store
%+ ~(jab by timebox) index
|= n=notification:store
?>(!=(read read.n) n(read read))
==
=/ tib=(unit timebox:store)
(get:orm notifications time)
?~ tib poke-core
=/ not=(unit notification:store)
(~(get by u.tib) index)
?~ not poke-core
=? poke-core
:: cache is inconsistent iff we didn't directly
:: call this through %read-note or %unread-note
&(=(read read.u.not) !?=(?(%read-note %unread-note) -.in))
~& >> "Inconsistent hark cache, rebuilding"
rebuild-cache
=. u.tib
(~(put by u.tib) index u.not(read read))
=. notifications
(put:orm notifications time u.tib)
poke-core
::
++ read-note
|= [time=@da =index:store]
@ -477,6 +538,10 @@
poke-core
?. (stats-index-is-index:store stats-index i.keys)
$(keys t.keys)
=/ =notification:store
(~(got by (gut-orm notifications time)) i.keys)
?: read.notification
$(keys t.keys)
=/ core
(read-note time i.keys)
$(poke-core core, keys t.keys)
@ -636,7 +701,7 @@
==
::
++ inflate-cache
|= state-2
|= state-3
^+ +.state
=/ nots=(list [p=@da =timebox:store])
(tap:orm notifications)

View File

@ -24,6 +24,6 @@
<div id="portal-root"></div>
<script src="/~landscape/js/channel.js"></script>
<script src="/~landscape/js/session.js"></script>
<script src="/~landscape/js/bundle/index.2ddb586104e8758c6863.js"></script>
<script src="/~landscape/js/bundle/index.6056641fbc32a19ee0fd.js"></script>
</body>
</html>

126
pkg/arvo/gen/tally.hoon Normal file
View File

@ -0,0 +1,126 @@
/- gr=group, md=metadata-store, ga=graph-store
/+ re=resource
!:
:- %say
|= $: [now=@da eny=@uvJ =beak]
args=?(~ [shy=? ~])
~
==
::
=/ shy=? ?~(args & shy.args)
=* our=@p p.beak
::
|^
=; out=(list @t)
:- %tang
%- flop ::NOTE tang is bottom-up
:* ''
'tallied your activity score! find the results below.'
::
?: shy
'to show non-anonymized resource identifiers, +tally |'
'showing plain resource identifiers, share with care.'
::
'counted from groups and channels that you are hosting.'
'groups are listed with their member count.'
'channels are listed with activity from the past week:'
' - amount of top-level content'
' - amount of unique authors'
''
(snoc out '')
==
:: gather local non-dm groups, sorted by size
::
=/ groups=(list [local=? resource:re members=@ud])
%+ murn
%~ tap in
%~ key by
dir:(scry arch %y %group-store /groups)
|= i=@ta
=/ r=resource:re (de-path:re (stab i))
=/ g=(unit group:gr)
%+ scry (unit group:gr)
[%x %group-store [%groups (snoc (en-path:re r) %noun)]]
?: |(?=(~ g) hidden.u.g)
~
`[=(our entity.r) r ~(wyt in members.u.g)]
=/ crowds=(list [resource:re @ud])
%+ sort (turn (skim groups head) tail)
|= [[* a=@ud] [* b=@ud]]
(gth a b)
:: gather local per-group channels
::
=/ channels=(map resource:re (list [module=term =resource:re]))
%- ~(gas by *(map resource:re (list [module=term =resource:re])))
%+ turn crowds
|= [r=resource:re *]
:- r
%+ murn
%~ tap by
%+ scry associations:md
[%x %metadata-store [%group (snoc (en-path:re r) %noun)]]
|= [[* m=md-resource:md] metadata:md]
::NOTE we only count graphs for now
?. &(=(%graph app-name.m) =(our creator)) ~
`[module (de-path:re app-path.m)]
:: count activity per channel
::
=/ activity=(list [resource:re members=@ud (list [resource:re mod=term week=@ud authors=@ud])])
%+ turn crowds
|= [g=resource:re m=@ud]
:+ g m
%+ turn (~(got by channels) g)
|= [m=term r=resource:re]
:+ r m
::NOTE graph-store doesn't use the full resource-style path here!
=/ upd=update:ga
%+ scry update:ga
[%x %graph-store /graph/(scot %p entity.r)/[name.r]/noun]
?> ?=(%add-graph -.q.upd)
=/ mo ((ordered-map atom node:ga) gth)
=/ week=(list [@da node:ga])
(tap:mo (subset:mo graph.q.upd ~ `(sub now ~d7)))
:- (lent week)
%~ wyt in
%+ roll week
|= [[* [author=ship *] *] a=(set ship)]
(~(put in a) author)
:: render results
::
:- (tac 'the date is ' (scot %da now))
:- :(tac 'you are in ' (render-number (lent groups)) ' group(s):')
:- =- (roll - tac)
%+ join ', '
%+ turn groups
|=([* r=resource:re *] (render-resource r))
:- :(tac 'you are hosting ' (render-number (lent crowds)) ' group(s):')
%- zing
%+ turn activity
|= [g=resource:re m=@ud chans=(list [resource:re term @ud @ud])]
^- (list @t)
:- :(tac 'group, ' (render-resource g) ', ' (render-number m))
%+ turn chans
|= [c=resource:re m=term w=@ud a=@ud]
;: tac ' chan, '
(render-resource c) ', '
m ', '
(render-number w) ', '
(render-number a)
==
::
++ scry
|* [=mold care=term app=term =path]
.^(mold (tac %g care) (scot %p our) app (scot %da now) path)
::
++ tac (cury cat 3)
::
++ render-resource
|= r=resource:re
?: shy
(crip ((x-co:co 8) (mug r)))
:(tac (scot %p entity.r) '/' name.r)
::
++ render-number
|= n=@ud
(crip ((d-co:co 1) n))
--

View File

@ -49,6 +49,14 @@
?> ?=(^ nodes.q.update)
q.n.nodes.q.update
::
++ check-node-existence
|= [res=resource =index:store]
^- ?
%+ scry-for ,?
%+ weld
/node-exists/(scot %p entity.res)/[name.res]
(turn index (cury scot %ud))
::
++ get-update-log
|= rid=resource
^- update-log:store