mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 16:14:51 +09:00
(Hopefully correctly) fill project inboxes with ticket comment Create Notes
This commit is contained in:
parent
bad1844cfc
commit
322d09658e
3 changed files with 53 additions and 0 deletions
|
@ -363,6 +363,7 @@ RemoteMessage
|
|||
|
||||
UniqueRemoteMessageIdent instance ident
|
||||
UniqueRemoteMessage rest
|
||||
UniqueRemoteMessageCreate create
|
||||
|
||||
RepoCollab
|
||||
repo RepoId
|
||||
|
|
|
@ -31,12 +31,14 @@ import Data.ByteString (ByteString)
|
|||
import Data.Default.Class
|
||||
import Data.Default.Instances.ByteString ()
|
||||
import Data.Foldable (traverse_, for_)
|
||||
import Data.List (nub)
|
||||
import Data.Maybe
|
||||
import Data.Proxy
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Encoding (encodeUtf8)
|
||||
import Data.Time.Calendar (Day (..))
|
||||
import Data.Time.Clock
|
||||
import Data.Traversable
|
||||
import Database.Persist
|
||||
import Database.Persist.BackendDataType (backendDataType, PersistDefault (..))
|
||||
import Database.Persist.Migration
|
||||
|
@ -61,6 +63,7 @@ import Web.ActivityPub
|
|||
import Yesod.FedURI
|
||||
import Yesod.Hashids
|
||||
|
||||
import Data.Either.Local
|
||||
import Database.Persist.Local
|
||||
|
||||
import Vervis.Model.Ident
|
||||
|
@ -609,6 +612,43 @@ changes hLocal ctx =
|
|||
"Inbox"
|
||||
-- 107
|
||||
, addUnique "Project" $ Unique "UniqueProjectInbox" ["inbox"]
|
||||
-- 108
|
||||
, addUnique "RemoteMessage" $ Unique "UniqueRemoteMessageCreate" ["create"]
|
||||
-- 109
|
||||
, unchecked $ lift $ do
|
||||
ibiids <- selectKeysList ([] :: [Filter InboxItem2019Fill]) []
|
||||
activities <- for ibiids $ \ ibiid ->
|
||||
requireEitherAlt
|
||||
(fmap inboxItemLocal2019FillActivity <$>
|
||||
getValBy (UniqueInboxItemLocalItem2019Fill ibiid)
|
||||
)
|
||||
(fmap inboxItemRemote2019FillActivity <$>
|
||||
getValBy (UniqueInboxItemRemoteItem2019Fill ibiid)
|
||||
)
|
||||
"InboxItem neither remote nor local"
|
||||
"InboxItem both remote and local"
|
||||
let getValByJust = fmap fromJust . getValBy
|
||||
for_ (nub activities) $ \ activity -> do
|
||||
mid <- case activity of
|
||||
Left obid ->
|
||||
localMessage2019FillRest <$>
|
||||
getValByJust
|
||||
(UniqueLocalMessageCreate2019Fill obid)
|
||||
Right ractid ->
|
||||
remoteMessage2019FillRest <$>
|
||||
getValByJust
|
||||
(UniqueRemoteMessageCreate2019Fill ractid)
|
||||
did <- message2019FillRoot <$> getJust mid
|
||||
mt <- getValBy $ UniqueTicketDiscussion2019Fill did
|
||||
for_ mt $ \ t -> do
|
||||
ibid <-
|
||||
project2019FillInbox <$> getJust (ticket2019FillProject t)
|
||||
ibiid <- insert $ InboxItem2019Fill False
|
||||
case activity of
|
||||
Left obid ->
|
||||
insert_ $ InboxItemLocal2019Fill ibid obid ibiid
|
||||
Right ractid ->
|
||||
insert_ $ InboxItemRemote2019Fill ibid ractid ibiid
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -70,6 +70,15 @@ module Vervis.Migration.Model
|
|||
, InboxItemRemote20190607
|
||||
, Project20190609
|
||||
, Inbox20190609Generic (..)
|
||||
, InboxItem2019FillGeneric (..)
|
||||
, InboxItem2019Fill
|
||||
, InboxItemLocal2019FillGeneric (..)
|
||||
, InboxItemRemote2019FillGeneric (..)
|
||||
, Project2019FillGeneric (..)
|
||||
, Ticket2019FillGeneric (..)
|
||||
, Message2019FillGeneric (..)
|
||||
, LocalMessage2019FillGeneric (..)
|
||||
, RemoteMessage2019FillGeneric (..)
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -171,3 +180,6 @@ makeEntitiesMigration "20190607"
|
|||
|
||||
makeEntitiesMigration "20190609"
|
||||
$(modelFile "migrations/2019_06_09.model")
|
||||
|
||||
makeEntitiesMigration "2019Fill"
|
||||
$(modelFile "migrations/2019_06_09_fill.model")
|
||||
|
|
Loading…
Reference in a new issue