-graph-add-nodes: return (map index hash) upon completion and finish out the json conversion

This commit is contained in:
Logan Allen 2021-02-26 14:05:11 -06:00
parent c5e846d573
commit b2ef9044a6
4 changed files with 54 additions and 3 deletions

View File

@ -17,6 +17,7 @@
leave+leave
groupify+groupify
eval+so
pending-indices+pending-indices
::invite+invite
==
::
@ -51,6 +52,14 @@
:~ resource+(un dejs:resource)
to+(uf ~ (mu dejs:resource))
==
::
++ pending-indices (op ;~(pfix fas (more fas dem)) nu)
:: NOTE: move these functions to zuse
++ nu :: parse number as hex
|= jon=json
?> ?=([%s *] jon)
(rash p.jon hex)
::
++ invite !!
::
++ associated
@ -60,4 +69,34 @@
==
--
--
++ enjs
=, enjs:format
|%
++ action
|= act=action
^- json
?> ?=(%pending-indices -.act)
%+ frond %pending-indices
:- %a
%+ turn ~(tap by pending.act)
|= [i=index:store h=hash:store]
%- pairs
:~ [%index (index i)]
[%hash s+(scot %ux h)]
==
::
++ index
|= i=^index
^- json
?: =(~ i) s+'/'
=/ j=^tape ""
|-
?~ i [%s (crip j)]
=/ k=json (numb i.i)
?> ?=(%n -.k)
%_ $
i t.i
j (weld j (weld "/" (trip +.k)))
==
--
--

View File

@ -4,6 +4,7 @@
++ grow
|%
++ noun act
++ json (action:enjs act)
--
++ grab
|%

View File

@ -42,6 +42,7 @@
[%groupify rid=resource to=(unit resource)]
[%forward rid=resource =update:store]
[%eval =cord]
[%pending-indices pending=(map index:store hash:store)]
==
--

View File

@ -1,5 +1,5 @@
/- spider
/+ strandio, store=graph-store, graph
/+ strandio, store=graph-store, graph, graph-view
=, strand=strand:spider
^- thread:spider
|= arg=vase
@ -14,12 +14,12 @@
%+ turn
(concat-by-parent (sort-nodes nodes.q.update))
add-hash-to-node
=/ hashes (nodes-to-pending-indices nodes.q.update)
;< ~ bind:m
%^ poke-our %graph-push-hook
%graph-update
!>(update)
:: TODO: send back a JSON response with a (map index:store hash:store)
(pure:m !>(~))
(pure:m !>(`action:graph-view`[%pending-indices hashes]))
::
++ sort-nodes
|= nodes=(map index:store node:store)
@ -105,4 +105,14 @@
resource.q.update
(snip `(list atom)`index)
hash.post.node
::
++ nodes-to-pending-indices
|= nodes=(map index:store node:store)
^- (map index:store hash:store)
%- ~(gas by *(map index:store hash:store))
%+ turn ~(tap by nodes)
|= [=index:store =node:store]
^- [index:store hash:store]
?> ?=(^ hash.post.node)
[index u.hash.post.node]
--