From e0de4cdcc793ba3411227fc510ce0769e107fc8b Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 18 Mar 2019 20:18:25 +0000 Subject: [PATCH] Remove Discussion's nextMessage field, it's not being used anymore --- config/models | 1 - src/Vervis/Handler/Ticket.hs | 5 +---- src/Vervis/Migration.hs | 2 ++ src/Vervis/Ticket.hs | 8 +++++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/models b/config/models index c0f4878..24a6777 100644 --- a/config/models +++ b/config/models @@ -218,7 +218,6 @@ TicketClaimRequest UniqueTicketClaimRequest person ticket Discussion - nextMessage Int Message author PersonId diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 5ed47ff..fdce0e2 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -133,10 +133,7 @@ postTicketsR shar proj = do now <- liftIO getCurrentTime tnum <- runDB $ do update pid [ProjectNextTicket +=. 1] - let discussion = Discussion - { discussionNextMessage = 1 - } - did <- insert discussion + did <- insert Discussion let ticket = Ticket { ticketProject = pid , ticketNumber = projectNextTicket project diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index bd6b490..4f81a70 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -197,6 +197,8 @@ changes = , removeUnique "Message" "UniqueMessage" -- 44 , removeField "Message" "number" + -- 45 + , removeField "Discussion" "nextMessage" ] migrateDB :: MonadIO m => ReaderT SqlBackend m (Either Text (Int, Int)) diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index 170213b..4828362 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018 by fr33domlover . + - Written in 2016, 2018, 2019 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -58,11 +58,13 @@ getTicketSummaries mfilt morder jid = do , tsComments = r } fmap (map toSummary) $ select $ from $ - \ (t `InnerJoin` p `InnerJoin` s `InnerJoin` d) -> do + \ (t `InnerJoin` p `InnerJoin` s `InnerJoin` d `LeftOuterJoin` m) -> do + on $ just (d ^. DiscussionId) ==. m ?. MessageRoot on $ t ^. TicketDiscuss ==. d ^. DiscussionId on $ p ^. PersonIdent ==. s ^. SharerId on $ t ^. TicketCreator ==. p ^. PersonId where_ $ t ^. TicketProject ==. val jid + groupBy $ d ^. DiscussionId for_ mfilt $ \ filt -> where_ $ filt t for_ morder $ \ order -> orderBy $ order t return @@ -71,7 +73,7 @@ getTicketSummaries mfilt morder jid = do , t ^. TicketCreated , t ^. TicketTitle , t ^. TicketStatus - , d ^. DiscussionNextMessage -. val 1 + , count $ m ?. MessageId ) -- | Get the child-parent ticket number pairs of all the ticket dependencies