From e931a473dd52614304b50c2dcbfc31a16fc82542 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 19 May 2020 19:47:07 -0600 Subject: [PATCH] os1: migrate app data to new group --- pkg/arvo/app/publish.hoon | 8 ++++ pkg/arvo/ted/migrate-group.hoon | 79 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 pkg/arvo/ted/migrate-group.hoon diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon index 7ad1ce308..f7b729986 100644 --- a/pkg/arvo/app/publish.hoon +++ b/pkg/arvo/app/publish.hoon @@ -415,6 +415,14 @@ (~(get by comments.limbo) u.host book-name note-name u.comment-date) ?~ comment ~ ``noun+!>(u.comment) + :: + [%x %book @ @ ~] + =/ host=(unit @p) (slaw %p i.t.t.pax) + =/ book-name i.t.t.t.pax + ?~ host [~ ~] + =/ book (~(get by books) u.host book-name) + ?~ book ~ + ``noun+!>(u.book) == :: ++ on-agent diff --git a/pkg/arvo/ted/migrate-group.hoon b/pkg/arvo/ted/migrate-group.hoon new file mode 100644 index 000000000..81512e538 --- /dev/null +++ b/pkg/arvo/ted/migrate-group.hoon @@ -0,0 +1,79 @@ +/- spider, *metadata-store, *publish +/+ strandio +=, strand=strand:spider +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=/ [og-path=path ng-path=path ~] !<([path path ~] arg) +;< bol=bowl:spider bind:m get-bowl:strandio +:: +=/ gs-path /(scot %p our.bol)/group-store/(scot %da now.bol) +=/ ms-path /(scot %p our.bol)/metadata-store/(scot %da now.bol) +=/ p-path /(scot %p our.bol)/publish/(scot %da now.bol) +:: +=/ og=(unit (set ship)) + .^((unit (set ship)) %gx :(weld gs-path og-path /noun)) +?~ og + (pure:m !>("no such group: {}")) +=/ ng=(unit (set ship)) + .^((unit (set ship)) %gx :(weld gs-path ng-path /noun)) +?~ ng + (pure:m !>("no such group: {}")) +:: +=/ ass=associations .^(associations %gx :(weld ms-path /group og-path /noun)) +=/ ass-list=(list [[group-path resource] metadata]) ~(tap by ass) +:: +|- +=* loop $ +?~ ass-list + (pure:m !>("done")) +=/ [[g-path=group-path res=resource] meta=metadata] i.ass-list +?. =(our.bol creator.meta) + loop(ass-list t.ass-list) +?. =(g-path og-path) + loop(ass-list t.ass-list) +=/ output=(list card:agent:gall) + ?+ app-name.res ~ + :: + ?(%chat %link) + %- (slog leaf+"migrating {} : {}" ~) + :~ :* %pass /poke %agent + [our.bol %metadata-hook] + %poke %metadata-action + !>([%add ng-path res meta]) + == + :* %pass /poke %agent + [our.bol %metadata-hook] + %poke %metadata-action + !>([%remove g-path res]) + == + == + %publish + %- (slog leaf+"migrating {} : {}" ~) + =/ book .^(notebook %gx :(weld p-path /book app-path.res /noun)) + ?> ?=([@tas @tas ~] app-path.res) + :~ :* %pass /poke %agent + [our.bol %publish] + %poke %publish-action + !> + :* %edit-book + i.t.app-path.res + title.book + description.book + comments.book + `[ng-path ~ %.y %.n] + == + == + :* %pass /poke %agent + [our.bol %metadata-hook] + %poke %metadata-action + !>([%remove g-path res]) + == + == + == +:: +;< ~ bind:m (send-raw-cards:strandio output) +;< ~ bind:m + (poke-our:strandio %group-store %group-action !>([%unbundle og-path])) +loop(ass-list t.ass-list)