diff --git a/config/models b/config/models index 7c6d32e..0303dc8 100644 --- a/config/models +++ b/config/models @@ -368,13 +368,11 @@ LocalTicket UniqueLocalTicketFollowers followers TicketAuthorLocal - ticket TicketId - ticketNew LocalTicketId + ticket LocalTicketId author PersonId offer OutboxItemId - UniqueTicketAuthorLocal ticket - UniqueTicketAuthorLocalNew ticketNew + UniqueTicketAuthorLocal ticket UniqueTicketAuthorLocalOffer offer TicketAuthorRemote diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index 81163f5..ebab05b 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -868,8 +868,7 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT , localTicketFollowers = fsid } insert_ TicketAuthorLocal - { ticketAuthorLocalTicket = tid - , ticketAuthorLocalTicketNew = ltid + { ticketAuthorLocalTicket = ltid , ticketAuthorLocalAuthor = pidAuthor , ticketAuthorLocalOffer = obiid } diff --git a/src/Vervis/Handler/Client.hs b/src/Vervis/Handler/Client.hs index cad9cd7..0b4c04c 100644 --- a/src/Vervis/Handler/Client.hs +++ b/src/Vervis/Handler/Client.hs @@ -695,19 +695,13 @@ postTicketsR shr prj = do obiid <- ExceptT $ offerTicketC shrAuthor summary audience offer ExceptT $ runDB $ do mtal <- getValBy $ UniqueTicketAuthorLocalOffer obiid - case mtal of - Nothing -> - return $ + return $ + case mtal of + Nothing -> Left "Offer processed successfully but no ticket \ \created" - Just tal -> do - let tid = ticketAuthorLocalTicket tal - mltid <- getKeyBy $ UniqueLocalTicket tid - return $ - case mltid of - Nothing -> Left "Weird, no LocalTicket created" - Just ltid -> Right ltid + Just tal -> Right $ ticketAuthorLocalTicket tal case eltid of Left e -> do setMessage $ toHtml e diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index a78455f..992acd3 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -257,7 +257,7 @@ getTicketR shar proj ltkhid = do unless (ticketProject ticket == jid) notFound author <- requireEitherAlt - (do mtal <- getValBy $ UniqueTicketAuthorLocal tid + (do mtal <- getValBy $ UniqueTicketAuthorLocal ltid for mtal $ \ tal -> do p <- getJust $ ticketAuthorLocalAuthor tal getJust $ personIdent p @@ -942,7 +942,7 @@ getTicketDeps forward shr prj ltkhid = do E.on $ E.just (t E.^. TicketId) E.==. tar E.?. TicketAuthorRemoteTicket E.on $ p E.?. PersonIdent E.==. s E.?. SharerId E.on $ tal E.?. TicketAuthorLocalAuthor E.==. p E.?. PersonId - E.on $ E.just (t E.^. TicketId) E.==. tal E.?. TicketAuthorLocalTicket + E.on $ E.just (lt E.^. LocalTicketId) E.==. tal E.?. TicketAuthorLocalTicket E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket E.on $ td E.^. to' E.==. t E.^. TicketId E.where_ $ td E.^. from' E.==. E.val tid diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index a41f188..1f9be59 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -1314,6 +1314,17 @@ changes hLocal ctx = -- 195 , addUnique "TicketAuthorLocal" $ Unique "UniqueTicketAuthorLocalNew" ["ticketNew"] + -- 196 + , removeUnique "TicketAuthorLocal" "UniqueTicketAuthorLocal" + -- 197 + , removeField "TicketAuthorLocal" "ticket" + -- 198 + , renameUnique + "TicketAuthorLocal" + "UniqueTicketAuthorLocalNew" + "UniqueTicketAuthorLocal" + -- 199 + , renameField "TicketAuthorLocal" "ticketNew" "ticket" ] migrateDB diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index ab7ce8d..edd7145 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -67,7 +67,7 @@ getTicketSummaries mfilt morder offlim jid = do on $ just (t ^. TicketId) ==. tar ?. TicketAuthorRemoteTicket on $ p ?. PersonIdent ==. s ?. SharerId on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId - on $ just (t ^. TicketId) ==. tal ?. TicketAuthorLocalTicket + on $ just (lt ^. LocalTicketId) ==. tal ?. TicketAuthorLocalTicket on $ t ^. TicketId ==. lt ^. LocalTicketTicket where_ $ t ^. TicketProject ==. val jid groupBy