From 1a5654f8aec8c6f9e9834b59523146adf2770bfc Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 3 Feb 2020 15:44:16 +0000 Subject: [PATCH] Stop assigning ticket numbers, allow them to be NULL --- config/models | 4 ++-- src/Vervis/API.hs | 12 +++++++----- src/Vervis/Federation/Ticket.hs | 4 +++- src/Vervis/Field/Ticket.hs | 2 +- src/Vervis/Handler/Ticket.hs | 2 +- src/Vervis/Migration.hs | 4 ++++ src/Vervis/Model.hs | 4 +++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/config/models b/config/models index 506690c..997cb0a 100644 --- a/config/models +++ b/config/models @@ -344,7 +344,7 @@ TicketParamClass Ticket project ProjectId - number Int + number Int Maybe created UTCTime title Text -- HTML source Text -- Pandoc Markdown @@ -357,7 +357,7 @@ Ticket followers FollowerSetId accept OutboxItemId - UniqueTicket project number + -- UniqueTicket project number UniqueTicketDiscussion discuss UniqueTicketFollowers followers UniqueTicketAccept accept diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index caf9f8b..0306300 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -763,9 +763,11 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT prj == prjProject && localRecipProject project -> do insertToInbox ibid + {- num <- ((subtract 1) . projectNextTicket) <$> updateGet jid [ProjectNextTicket +=. 1] + -} obiidAccept <- do obidProject <- projectOutbox <$> getJust jid now <- liftIO getCurrentTime @@ -776,9 +778,9 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT persistJSONObjectFromDoc $ Doc hLocal emptyActivity , outboxItemPublished = now } - tid <- insertTicket jid {-tids-} num obiidAccept + tid <- insertTicket jid {-tids-} {-num-} obiidAccept docAccept <- insertAccept pidAuthor sid jid fsid luOffer obiidAccept tid - publishAccept pidAuthor sid jid fsid luOffer num obiidAccept docAccept + publishAccept pidAuthor sid jid fsid luOffer {-num-} obiidAccept docAccept (pidsTeam, remotesTeam) <- if localRecipProjectTeam project then getProjectTeam sid @@ -841,12 +843,12 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT obiid [OutboxItemActivity =. persistJSONObjectFromDoc doc] return doc - insertTicket jid {-tidsDeps-} next obiidAccept = do + insertTicket jid {-tidsDeps-} {-next-} obiidAccept = do did <- insert Discussion fsid <- insert FollowerSet tid <- insert Ticket { ticketProject = jid - , ticketNumber = next + , ticketNumber = Nothing , ticketCreated = now , ticketTitle = unTextHtml $ AP.ticketSummary ticket , ticketSource = @@ -868,7 +870,7 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT --insertMany_ $ map (TicketDependency tid) tidsDeps -- insert_ $ Follow pidAuthor fsid False True return tid - publishAccept pidAuthor sid jid fsid luOffer num obiid doc = do + publishAccept pidAuthor sid jid fsid luOffer {-num-} obiid doc = do now <- liftIO getCurrentTime let dont = Authority "dont-do.any-forwarding" Nothing remotesHttp <- do diff --git a/src/Vervis/Federation/Ticket.hs b/src/Vervis/Federation/Ticket.hs index 1179816..9f903fa 100644 --- a/src/Vervis/Federation/Ticket.hs +++ b/src/Vervis/Federation/Ticket.hs @@ -240,9 +240,11 @@ projectOfferTicketF delete ibiid return Nothing Just _ibirid -> do + {- next <- ((subtract 1) . projectNextTicket) <$> updateGet jid [ProjectNextTicket +=. 1] + -} did <- insert Discussion fsid <- insert FollowerSet @@ -261,7 +263,7 @@ projectOfferTicketF tid <- insert Ticket { ticketProject = jid - , ticketNumber = next + , ticketNumber = Nothing , ticketCreated = now , ticketTitle = unTextHtml $ AP.ticketSummary ticket , ticketSource = diff --git a/src/Vervis/Field/Ticket.hs b/src/Vervis/Field/Ticket.hs index ba97bb2..ee39207 100644 --- a/src/Vervis/Field/Ticket.hs +++ b/src/Vervis/Field/Ticket.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2020 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 684c5d8..96c3045 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -895,7 +895,7 @@ getTicketDeps forward shr prj tkhid = do E.on $ E.just (t E.^. TicketId) E.==. tal E.?. TicketAuthorLocalTicket E.on $ td E.^. to' E.==. t E.^. TicketId E.where_ $ td E.^. from' E.==. E.val tid - E.orderBy [E.asc $ t E.^. TicketNumber] + E.orderBy [E.asc $ t E.^. TicketId] return ( td E.^. TicketDependencyId , t E.^. TicketId diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 33bb9e1..0ebada2 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -1229,6 +1229,10 @@ changes hLocal ctx = , addEntities model_2020_01_05 -- 185 , addFieldPrimOptional "WorkflowField" (Nothing :: Maybe Int) "color" + -- 186 + , removeUnique "Ticket" "UniqueTicket" + -- 187 + , setFieldMaybe "Ticket" "number" ] migrateDB diff --git a/src/Vervis/Model.hs b/src/Vervis/Model.hs index 5cb8ae3..724dbcc 100644 --- a/src/Vervis/Model.hs +++ b/src/Vervis/Model.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019 by fr33domlover . + - Written in 2016, 2018, 2019, 2020 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -90,7 +90,9 @@ instance PersistEntityGraphSelect Ticket TicketDependency where selectorParam _ = ticketProject selectorField _ = TicketProject +{- instance PersistEntityGraphNumbered Ticket TicketDependency where numberParam _ = ticketNumber numberField _ = TicketNumber uniqueNode _ = UniqueTicket +-}