From aeb1a83c933cdcffb6edbf2ea6f45f72cdfcd852 Mon Sep 17 00:00:00 2001 From: Pere Lev Date: Mon, 29 Apr 2024 14:38:37 +0300 Subject: [PATCH] DB: Add a Komponent record, to gather local repos/decks/looms/etc. --- migrations/626_2024-04-29_komponent.model | 4 + migrations/627_2024-04-29_komponent_mig.model | 69 ++++++++++++++ src/Vervis/API.hs | 4 + src/Vervis/Actor/Deck.hs | 39 ++++---- src/Vervis/Actor/Person/Client.hs | 2 + src/Vervis/Migration.hs | 89 +++++++++++++++++++ src/Vervis/Migration/Entities.hs | 4 + src/Vervis/Migration/Model2024.hs | 3 + th/models | 8 ++ 9 files changed, 203 insertions(+), 19 deletions(-) create mode 100644 migrations/626_2024-04-29_komponent.model create mode 100644 migrations/627_2024-04-29_komponent_mig.model diff --git a/migrations/626_2024-04-29_komponent.model b/migrations/626_2024-04-29_komponent.model new file mode 100644 index 0000000..9d0d6b3 --- /dev/null +++ b/migrations/626_2024-04-29_komponent.model @@ -0,0 +1,4 @@ +Komponent + resource ResourceId + + UniqueKomponent resource diff --git a/migrations/627_2024-04-29_komponent_mig.model b/migrations/627_2024-04-29_komponent_mig.model new file mode 100644 index 0000000..ba96c6d --- /dev/null +++ b/migrations/627_2024-04-29_komponent_mig.model @@ -0,0 +1,69 @@ +Workflow +OutboxItem + +Outbox + +Inbox + +FollowerSet + +Actor + name Text + desc Text + createdAt UTCTime + inbox InboxId + outbox OutboxId + followers FollowerSetId + justCreatedBy ActorId Maybe + errbox InboxId + + UniqueActorInbox inbox + UniqueActorOutbox outbox + UniqueActorFollowers followers + +Resource + actor ActorId + + UniqueResource actor + +Komponent + resource ResourceId + + UniqueKomponent resource + +Deck + actor ActorId + resource ResourceId + komponent KomponentId + workflow WorkflowId + nextTicket Int + wiki RepoId Maybe + create OutboxItemId + + UniqueDeckActor actor + UniqueDeckCreate create + +Loom + nextTicket Int + actor ActorId + resource ResourceId + komponent KomponentId + repo RepoId + create OutboxItemId + + UniqueLoomActor actor + UniqueLoomRepo repo + UniqueLoomCreate create + +Repo + vcs VersionControlSystem + project DeckId Maybe + mainBranch Text + actor ActorId + resource ResourceId + komponent KomponentId + create OutboxItemId + loom LoomId Maybe + + UniqueRepoActor actor + UniqueRepoCreate create diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index 6ec33fc..6876835 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -1132,10 +1132,12 @@ createPatchTrackerC (Entity pidUser personUser) senderActor maybeCap localRecips actor@(Entity actorID _) <- insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) resourceID <- insert $ Resource actorID + komponentID <- insert $ Komponent resourceID loomID <- insert Loom { loomNextTicket = 1 , loomActor = actorID , loomResource = resourceID + , loomKomponent = komponentID , loomRepo = repoID , loomCreate = obiidCreate } @@ -1369,12 +1371,14 @@ createRepositoryC (Entity pidUser personUser) senderActor maybeCap localRecips r actor@(Entity actorID _) <- insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) resourceID <- insert $ Resource actorID + komponentID <- insert $ Komponent resourceID repoID <- insert Repo { repoVcs = vcs , repoProject = Nothing , repoMainBranch = "main" , repoActor = actorID , repoResource = resourceID + , repoKomponent = komponentID , repoCreate = createID , repoLoom = Nothing } diff --git a/src/Vervis/Actor/Deck.hs b/src/Vervis/Actor/Deck.hs index 4de7496..af3358e 100644 --- a/src/Vervis/Actor/Deck.hs +++ b/src/Vervis/Actor/Deck.hs @@ -79,25 +79,26 @@ import Vervis.Web.Collab -- Meaning: An actor is adding some object to some target -- Behavior: --- * Verify that the object is me --- * Verify the target is some project's components collection URI --- * Verify the Add is authorized --- * For all the Stem records I have for this project: --- * Verify I'm not yet a member of the project --- * Verify I haven't already Accepted an Add to this project --- * Verify I haven't already seen an Invite-and-Project-accept for --- this project --- * Insert the Add to my inbox --- * Create a Stem record in DB --- * Forward the Add activity to my followers --- * Send an Accept on the Add: --- * To: --- * The author of the Add --- * The project --- * CC: --- * Author's followers --- * Project's followers --- * My followers +-- * If the object is me: +-- * Verify that the object is me +-- * Verify the target is some project's components collection URI +-- * Verify the Add is authorized +-- * For all the Stem records I have for this project: +-- * Verify I'm not yet a member of the project +-- * Verify I haven't already Accepted an our-Add to this project +-- * Verify I haven't already seen an them-Invite-and-Project-accept for +-- this project +-- * Insert the Add to my inbox +-- * Create a Stem record in DB +-- * Forward the Add activity to my followers +-- * Send an Accept on the Add: +-- * To: +-- * The author of the Add +-- * The project +-- * CC: +-- * Author's followers +-- * Project's followers +-- * My followers deckAdd :: UTCTime -> DeckId diff --git a/src/Vervis/Actor/Person/Client.hs b/src/Vervis/Actor/Person/Client.hs index d9b0e1d..5c7a4b4 100644 --- a/src/Vervis/Actor/Person/Client.hs +++ b/src/Vervis/Actor/Person/Client.hs @@ -462,9 +462,11 @@ clientCreateDeck now personMeID (ClientMsg maybeCap localRecips remoteRecips fwd insertDeck now name msummary obiidCreate wid actorMeID = do Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID) rid <- insert $ Resource aid + kid <- insert $ Komponent rid did <- insert Deck { deckActor = aid , deckResource = rid + , deckKomponent = kid , deckWorkflow = wid , deckNextTicket = 1 , deckWiki = Nothing diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 15115e8..4d60ade 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -3618,6 +3618,95 @@ changes hLocal ctx = ) "errbox" "Inbox" + -- 626 + , addEntities model_626_komponent + -- 627 + , addFieldRefRequired'' + "Repo" + (do inboxID <- insert Inbox627 + errboxID <- insert Inbox627 + outboxID <- insert Outbox627 + followerSetID <- insert FollowerSet627 + actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID + resourceID <- insert $ Resource627 actorID + insertEntity $ Komponent627 resourceID + ) + (Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do + l <- selectList [] [] + for_ l $ \ (Entity k v) -> do + kID <- insert $ Komponent627 $ repo627Resource v + update k [Repo627Komponent =. kID] + + Resource627 tempActorID <- getJust tempResourceID + Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID + delete tempKomponentID + delete tempResourceID + delete tempActorID + delete inboxID + delete errboxID + delete outboxID + delete followerSetID + ) + "komponent" + "Komponent" + -- 628 + , addFieldRefRequired'' + "Deck" + (do inboxID <- insert Inbox627 + errboxID <- insert Inbox627 + outboxID <- insert Outbox627 + followerSetID <- insert FollowerSet627 + actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID + resourceID <- insert $ Resource627 actorID + insertEntity $ Komponent627 resourceID + ) + (Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do + l <- selectList [] [] + for_ l $ \ (Entity k v) -> do + kID <- insert $ Komponent627 $ deck627Resource v + update k [Deck627Komponent =. kID] + + Resource627 tempActorID <- getJust tempResourceID + Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID + delete tempKomponentID + delete tempResourceID + delete tempActorID + delete inboxID + delete errboxID + delete outboxID + delete followerSetID + ) + "komponent" + "Komponent" + -- 629 + , addFieldRefRequired'' + "Loom" + (do inboxID <- insert Inbox627 + errboxID <- insert Inbox627 + outboxID <- insert Outbox627 + followerSetID <- insert FollowerSet627 + actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID + resourceID <- insert $ Resource627 actorID + insertEntity $ Komponent627 resourceID + ) + (Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do + l <- selectList [] [] + for_ l $ \ (Entity k v) -> do + kID <- insert $ Komponent627 $ loom627Resource v + update k [Loom627Komponent =. kID] + + Resource627 tempActorID <- getJust tempResourceID + Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID + delete tempKomponentID + delete tempResourceID + delete tempActorID + delete inboxID + delete errboxID + delete outboxID + delete followerSetID + ) + "komponent" + "Komponent" ] migrateDB diff --git a/src/Vervis/Migration/Entities.hs b/src/Vervis/Migration/Entities.hs index 3b5f203..633c022 100644 --- a/src/Vervis/Migration/Entities.hs +++ b/src/Vervis/Migration/Entities.hs @@ -75,6 +75,7 @@ module Vervis.Migration.Entities , model_592_permit_extend , model_601_permit_extend_resource , model_603_resource + , model_626_komponent ) where @@ -293,3 +294,6 @@ model_601_permit_extend_resource = model_603_resource :: [Entity SqlBackend] model_603_resource = $(schema "603_2024-04-20_resource") + +model_626_komponent :: [Entity SqlBackend] +model_626_komponent = $(schema "626_2024-04-29_komponent") diff --git a/src/Vervis/Migration/Model2024.hs b/src/Vervis/Migration/Model2024.hs index e49bbcd..0849827 100644 --- a/src/Vervis/Migration/Model2024.hs +++ b/src/Vervis/Migration/Model2024.hs @@ -69,3 +69,6 @@ makeEntitiesMigration "611" makeEntitiesMigration "625" $(modelFile "migrations/625_2024-04-27_errbox.model") + +makeEntitiesMigration "627" + $(modelFile "migrations/627_2024-04-29_komponent_mig.model") diff --git a/th/models b/th/models index 35490b0..17477b9 100644 --- a/th/models +++ b/th/models @@ -156,6 +156,11 @@ Resource UniqueResource actor +Komponent + resource ResourceId + + UniqueKomponent resource + -- ========================================================================= -- -- Delivery -- ========================================================================= -- @@ -307,6 +312,7 @@ Project Deck actor ActorId resource ResourceId + komponent KomponentId workflow WorkflowId nextTicket Int wiki RepoId Maybe @@ -319,6 +325,7 @@ Loom nextTicket Int actor ActorId resource ResourceId + komponent KomponentId repo RepoId create OutboxItemId @@ -332,6 +339,7 @@ Repo mainBranch Text actor ActorId resource ResourceId + komponent KomponentId create OutboxItemId loom LoomId Maybe