1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-03-20 15:14:54 +09:00

DB: Add LocalTicket table

This is a step preparing for the Create flow for tickets. Each Ticket now gets
a matching LocalTicket that points to it. But otherwise the LocalTicket isn't
in use yet.
This commit is contained in:
fr33domlover 2020-02-05 12:08:39 +00:00
parent 1a5654f8ae
commit deeac7e760
8 changed files with 88 additions and 5 deletions
src/Vervis

View file

@ -862,6 +862,11 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT
, ticketFollowers = fsid
, ticketAccept = obiidAccept
}
insert_ LocalTicket
{ localTicketTicket = tid
, localTicketDiscuss = did
, localTicketFollowers = fsid
}
insert_ TicketAuthorLocal
{ ticketAuthorLocalTicket = tid
, ticketAuthorLocalAuthor = pidAuthor

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2019 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -122,7 +122,7 @@ parseLocalRecipient r =
-- the code that fetches the actual recipients from the DB.
-------------------------------------------------------------------------------
data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowers
data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowerz
deriving (Eq, Ord)
data LocalProjectRecipientDirect
@ -188,7 +188,7 @@ groupedRecipientFromCollection
groupedRecipientFromCollection
(LocalPersonCollectionTicketFollowers shr prj num) =
LocalSharerRelated shr $ LocalProjectRelated prj $
LocalTicketRelated num LocalTicketFollowers
LocalTicketRelated num LocalTicketFollowerz
groupedRecipientFromCollection
(LocalPersonCollectionRepoTeam shr rp) =
LocalSharerRelated shr $ LocalRepoRelated rp $
@ -301,7 +301,7 @@ groupLocalRecipients
initial = LocalTicketDirectSet False False
f s LocalTicketTeam =
s { localRecipTicketTeam = True }
f s LocalTicketFollowers =
f s LocalTicketFollowerz =
s { localRecipTicketFollowers = True }
lrr2set = LocalRepoRelatedSet . foldl' f initial . NE.map unwrap
where

View file

@ -277,6 +277,11 @@ projectOfferTicketF
, ticketFollowers = fsid
, ticketAccept = obiidAccept
}
insert_ LocalTicket
{ localTicketTicket = tid
, localTicketDiscuss = did
, localTicketFollowers = fsid
}
insert_ TicketAuthorRemote
{ ticketAuthorRemoteTicket = tid
, ticketAuthorRemoteAuthor = raidAuthor

View file

@ -1233,6 +1233,17 @@ changes hLocal ctx =
, removeUnique "Ticket" "UniqueTicket"
-- 187
, setFieldMaybe "Ticket" "number"
-- 188
, addEntities model_2020_02_05
-- 189
, unchecked $ lift $ do
ts <- selectList ([] :: [Filter Ticket189]) []
let makeLT (Entity tid t) = LocalTicket189
{ localTicket189Ticket = tid
, localTicket189Discuss = ticket189Discuss t
, localTicket189Followers = ticket189Followers t
}
insertMany_ $ map makeLT ts
]
migrateDB

View file

@ -139,6 +139,10 @@ module Vervis.Migration.Model
, RemoteCollection159Generic (..)
, RemoteCollection159
, model_2020_01_05
, model_2020_02_05
, Ticket189
, Ticket189Generic (..)
, LocalTicket189Generic (..)
)
where
@ -146,7 +150,6 @@ import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Time (UTCTime)
import Database.Persist.Class (EntityField, Unique)
--import Database.Persist.JSON (PersistJSONValue)
import Database.Persist.Schema.Types (Entity)
import Database.Persist.Schema.SQL ()
import Database.Persist.Sql (SqlBackend)
@ -281,3 +284,8 @@ makeEntitiesMigration "159"
model_2020_01_05 :: [Entity SqlBackend]
model_2020_01_05 = $(schema "2020_01_05")
model_2020_02_05 :: [Entity SqlBackend]
model_2020_02_05 = $(schema "2020_02_05_local_ticket")
makeEntitiesMigration "189" $(modelFile "migrations/2020_02_05_mig.model")