1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 17:44:52 +09:00

UI, DB: Switch ticket filter to use TicketResolve instead of TicketStatus

This commit is contained in:
fr33domlover 2022-10-16 23:44:16 +00:00
parent 7ddb79d78d
commit d8c65930ca
6 changed files with 45 additions and 55 deletions

View file

@ -262,18 +262,9 @@ claimRequestForm = renderDivs claimRequestAForm
-}
ticketFilterAForm :: AForm Handler TicketFilter
ticketFilterAForm = mk
<$> areq checkBoxField "New" (Just True)
<*> areq checkBoxField "To-do" (Just True)
ticketFilterAForm = TicketFilter
<$> areq checkBoxField "Open" (Just True)
<*> areq checkBoxField "Closed" (Just False)
where
mk new todo closed =
TicketFilter $
catMaybes
[result new TSNew, result todo TSTodo, result closed TSClosed]
where
result False _ = Nothing
result True s = Just s
ticketFilterForm :: Form TicketFilter
ticketFilterForm = renderDivs ticketFilterAForm

View file

@ -97,7 +97,7 @@ import Vervis.Widget.Ticket
-- | Get summaries of all the tickets in the given project.
getTicketSummaries
:: Maybe (E.SqlExpr (Entity Ticket) -> E.SqlExpr (E.Value Bool))
:: Maybe (E.SqlExpr (Maybe (Entity TicketResolve)) -> E.SqlExpr (E.Value Bool))
-> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy])
-> Maybe (Int, Int)
-> DeckId
@ -108,12 +108,15 @@ getTicketSummaries mfilt morder offlim deckID = do
`E.InnerJoin` td
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a)
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
`E.LeftOuterJoin` tr
`E.InnerJoin` d
`E.LeftOuterJoin` m
) -> do
E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot
E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId
E.on $ E.just (t E.^. TicketId) E.==. tr E.?. TicketResolveTicket
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
@ -127,11 +130,12 @@ getTicketSummaries mfilt morder offlim deckID = do
E.where_ $ td E.^. TicketDeckDeck E.==. E.val deckID
E.groupBy
( t E.^. TicketId, td E.^. TicketDeckId
( (t E.^. TicketId, td E.^. TicketDeckId)
, tr E.?. TicketResolveId
, tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId
, ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId
)
for_ mfilt $ \ filt -> E.where_ $ filt t
for_ mfilt $ \ filt -> E.where_ $ filt tr
for_ morder $ \ order -> E.orderBy $ order t
for_ offlim $ \ (off, lim) -> do
E.offset $ fromIntegral off
@ -144,12 +148,12 @@ getTicketSummaries mfilt morder offlim deckID = do
, i, ro, ra
, t E.^. TicketCreated
, t E.^. TicketTitle
, t E.^. TicketStatus
, tr E.?. TicketResolveId
, E.count $ m E.?. MessageId
)
for tickets $
\ (E.Value tid, E.Value tdid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value d, E.Value r) -> do
\ (E.Value tid, E.Value tdid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value mc, E.Value r) -> do
labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do
E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId
E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid
@ -166,12 +170,12 @@ getTicketSummaries mfilt morder offlim deckID = do
, tsCreatedAt = c
, tsTitle = t
, tsLabels = map entityVal labels
, tsStatus = d
, tsClosed = isJust mc
, tsComments = r
}
getClothSummaries
:: Maybe (E.SqlExpr (Entity Ticket) -> E.SqlExpr (E.Value Bool))
:: Maybe (E.SqlExpr (Maybe (Entity TicketResolve)) -> E.SqlExpr (E.Value Bool))
-> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy])
-> Maybe (Int, Int)
-> LoomId
@ -182,12 +186,15 @@ getClothSummaries mfilt morder offlim loomID = do
`E.InnerJoin` tl
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a)
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
`E.LeftOuterJoin` tr
`E.InnerJoin` d
`E.LeftOuterJoin` m
) -> do
E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot
E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId
E.on $ E.just (t E.^. TicketId) E.==. tr E.?. TicketResolveTicket
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
@ -201,11 +208,12 @@ getClothSummaries mfilt morder offlim loomID = do
E.where_ $ tl E.^. TicketLoomLoom E.==. E.val loomID
E.groupBy
( t E.^. TicketId, tl E.^. TicketLoomId
( (t E.^. TicketId, tl E.^. TicketLoomId)
, tr E.?. TicketResolveId
, tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId
, ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId
)
for_ mfilt $ \ filt -> E.where_ $ filt t
for_ mfilt $ \ filt -> E.where_ $ filt tr
for_ morder $ \ order -> E.orderBy $ order t
for_ offlim $ \ (off, lim) -> do
E.offset $ fromIntegral off
@ -218,12 +226,12 @@ getClothSummaries mfilt morder offlim loomID = do
, i, ro, ra
, t E.^. TicketCreated
, t E.^. TicketTitle
, t E.^. TicketStatus
, tr E.?. TicketResolveId
, E.count $ m E.?. MessageId
)
for tickets $
\ (E.Value tid, E.Value tlid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value d, E.Value r) -> do
\ (E.Value tid, E.Value tlid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value mc, E.Value r) -> do
labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do
E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId
E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid
@ -240,7 +248,7 @@ getClothSummaries mfilt morder offlim loomID = do
, csCreatedAt = c
, csTitle = t
, csLabels = map entityVal labels
, csStatus = d
, csClosed = isJust mc
, csComments = r
}

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2016, 2018, 2019 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018, 2019, 2022 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -26,19 +26,18 @@ import Vervis.Model
import Vervis.Model.Ticket
data TicketFilter = TicketFilter
{ tfStatus :: [TicketStatus]
{ tfOpen :: Bool
, tfClosed :: Bool
}
instance Default TicketFilter where
def = TicketFilter
{ tfStatus = []
}
def = TicketFilter True True
filterTickets
:: Esqueleto q e b
=> TicketFilter
-> Maybe (e (Entity Ticket) -> e (Value Bool))
filterTickets (TicketFilter s) =
if null s
then Nothing
else Just $ \ t -> t ^. TicketStatus `in_` valList s
-> Maybe (e (Maybe (Entity TicketResolve)) -> e (Value Bool))
filterTickets (TicketFilter False False) = Just $ \ _ -> val (0::Int) ==. val 1
filterTickets (TicketFilter False True) = Just $ \ t -> not_ $ isNothing $ t ?. TicketResolveId
filterTickets (TicketFilter True False) = Just $ \ t -> isNothing $ t ?. TicketResolveId
filterTickets (TicketFilter True True) = Nothing

View file

@ -61,7 +61,7 @@ data TicketSummary = TicketSummary
, tsCreatedAt :: UTCTime
, tsTitle :: Text
, tsLabels :: [WorkflowField]
, tsStatus :: TicketStatus
, tsClosed :: Bool
, tsComments :: Int
}
@ -73,7 +73,7 @@ data ClothSummary = ClothSummary
, csCreatedAt :: UTCTime
, csTitle :: Text
, csLabels :: [WorkflowField]
, csStatus :: TicketStatus
, csClosed :: Bool
, csComments :: Int
}

View file

@ -13,16 +13,12 @@ $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
<span .ticket-status-column>
$case csStatus cs
$of TSNew
<span .#{cNew}>
$of TSTodo
<span .#{cTodo}>
$of TSClosed
<span .#{cClosed}>
$if csClosed cs
<span .#{cClosed}>
$else
<span .#{cTodo}>
<span .ticket-number-column>
<a href=@{ticketRoute cs}>

View file

@ -13,16 +13,12 @@ $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
<span .ticket-status-column>
$case tsStatus ts
$of TSNew
<span .#{cNew}>
$of TSTodo
<span .#{cTodo}>
$of TSClosed
<span .#{cClosed}>
$if tsClosed ts
<span .#{cClosed}>
$else
<span .#{cTodo}>
<span .ticket-number-column>
<a href=@{ticketRoute ts}>