DB: Simplify ComponentGather using the new DestUsStart
This commit is contained in:
parent
b47941af97
commit
8024e993a2
5 changed files with 28 additions and 30 deletions
7
migrations/591_2024-04-14_component_gather.model
Normal file
7
migrations/591_2024-04-14_component_gather.model
Normal file
|
@ -0,0 +1,7 @@
|
|||
ComponentGather
|
||||
component ComponentEnableId
|
||||
parent DestUsStartId
|
||||
grant OutboxItemId
|
||||
|
||||
UniqueComponentGather component parent
|
||||
UniqueComponentGatherGrant grant
|
|
@ -3345,9 +3345,7 @@ projectGrant now projectID (Verse authorIdMsig body) grant = do
|
|||
)
|
||||
localExtensions <- lift $ for localComponents $ \ (E.Value startID, Entity componentID component, Entity enableID _) -> do
|
||||
extID <- insertEmptyOutboxItem' (actorOutbox recipActor) now
|
||||
case to of
|
||||
Left localID -> insert_ $ ComponentGatherLocal enableID localID extID
|
||||
Right remoteID -> insert_ $ ComponentGatherRemote enableID remoteID extID
|
||||
insert_ $ ComponentGather enableID destStartID extID
|
||||
componentIdent <- do
|
||||
i <- getComponentIdent componentID
|
||||
bitraverse
|
||||
|
@ -3382,9 +3380,7 @@ projectGrant now projectID (Verse authorIdMsig body) grant = do
|
|||
)
|
||||
remoteExtensions <- lift $ for remoteComponents $ \ (E.Value startID, Entity componentID component, Entity enableID _) -> do
|
||||
extID <- insertEmptyOutboxItem' (actorOutbox recipActor) now
|
||||
case to of
|
||||
Left localID -> insert_ $ ComponentGatherLocal enableID localID extID
|
||||
Right remoteID -> insert_ $ ComponentGatherRemote enableID remoteID extID
|
||||
insert_ $ ComponentGather enableID destStartID extID
|
||||
componentIdent <- do
|
||||
i <- getComponentIdent componentID
|
||||
bitraverse
|
||||
|
@ -4581,11 +4577,7 @@ projectRemove now projectID (Verse authorIdMsig body) remove = do
|
|||
lift $ for maybeRemoveDB $ \ _removeDB -> do
|
||||
|
||||
-- Delete uses of this Dest from my Component records
|
||||
case topic of
|
||||
Left (_, _, sendID) ->
|
||||
deleteWhere [ComponentGatherLocalParent ==. sendID]
|
||||
Right (_, sendID) ->
|
||||
deleteWhere [ComponentGatherRemoteParent ==. sendID]
|
||||
deleteWhere [ComponentGatherParent ==. destStartID]
|
||||
|
||||
-- Delete uses of this Dest from my Source records
|
||||
gatherIDs <- selectKeysList [SourceUsGatherDest ==. destStartID] []
|
||||
|
@ -4996,15 +4988,12 @@ projectRevoke now projectID (Verse authorIdMsig body) (AP.Revoke (luFirst :| lus
|
|||
maybeRevokeDB <- lift $ insertToInbox now authorIdMsig body (actorInbox actorRecip) False
|
||||
lift $ for maybeRevokeDB $ \ _revokeDB -> do
|
||||
|
||||
-- Delete uses of this Dest from my Component records
|
||||
case send of
|
||||
Left sendID ->
|
||||
deleteWhere [ComponentGatherLocalParent ==. sendID]
|
||||
Right sendID ->
|
||||
deleteWhere [ComponentGatherRemoteParent ==. sendID]
|
||||
|
||||
maybeStartID <- getKeyBy $ UniqueDestUsStart usAcceptID
|
||||
|
||||
-- Delete uses of this Dest from my Component records
|
||||
for_ maybeStartID $ \ destStartID ->
|
||||
deleteWhere [ComponentGatherParent ==. destStartID]
|
||||
|
||||
-- Delete uses of this Dest from my Source records
|
||||
for_ maybeStartID $ \ destStartID -> do
|
||||
gatherIDs <- selectKeysList [SourceUsGatherDest ==. destStartID] []
|
||||
|
|
|
@ -3247,6 +3247,12 @@ changes hLocal ctx =
|
|||
, removeEntity "SourceUsGatherToLocal"
|
||||
-- 588
|
||||
, removeEntity "SourceUsGatherToRemote"
|
||||
-- 589
|
||||
, removeEntity "ComponentGatherLocal"
|
||||
-- 590
|
||||
, removeEntity "ComponentGatherRemote"
|
||||
-- 591
|
||||
, addEntities model_591_component_gather
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -71,6 +71,7 @@ module Vervis.Migration.Entities
|
|||
, model_577_component_gather
|
||||
, model_578_source_remove
|
||||
, model_583_dest_start
|
||||
, model_591_component_gather
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -276,3 +277,6 @@ model_578_source_remove = $(schema "578_2024-04-03_source_remove")
|
|||
|
||||
model_583_dest_start :: [Entity SqlBackend]
|
||||
model_583_dest_start = $(schema "583_2024-04-13_dest_start")
|
||||
|
||||
model_591_component_gather :: [Entity SqlBackend]
|
||||
model_591_component_gather = $(schema "591_2024-04-14_component_gather")
|
||||
|
|
16
th/models
16
th/models
|
@ -1104,21 +1104,13 @@ ComponentFurtherRemote
|
|||
-- Witnesses that the project has extended a given delegation to a given
|
||||
-- parent
|
||||
|
||||
ComponentGatherLocal
|
||||
ComponentGather
|
||||
component ComponentEnableId
|
||||
parent DestThemSendDelegatorLocalId
|
||||
parent DestUsStartId
|
||||
grant OutboxItemId
|
||||
|
||||
UniqueComponentGatherLocal component parent
|
||||
UniqueComponentGatherLocalGrant grant
|
||||
|
||||
ComponentGatherRemote
|
||||
component ComponentEnableId
|
||||
parent DestThemSendDelegatorRemoteId
|
||||
grant OutboxItemId
|
||||
|
||||
UniqueComponentGatherRemote component parent
|
||||
UniqueComponentGatherRemoteGrant grant
|
||||
UniqueComponentGather component parent
|
||||
UniqueComponentGatherGrant grant
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Components, from component perspective
|
||||
|
|
Loading…
Reference in a new issue