Vervis.Handler.Ticket: Import esqueleto qualified
This commit is contained in:
parent
3af54ef300
commit
ae1e10cab2
4 changed files with 53 additions and 54 deletions
|
@ -68,8 +68,7 @@ import Data.Time.Calendar (Day (..))
|
|||
import Data.Time.Clock (UTCTime (..), getCurrentTime)
|
||||
import Data.Time.Format (formatTime, defaultTimeLocale)
|
||||
import Data.Traversable (for)
|
||||
import Database.Esqueleto hiding ((=.), (+=.), update, delete)
|
||||
import Database.Persist hiding ((==.))
|
||||
import Database.Persist
|
||||
import Network.HTTP.Types (StdMethod (DELETE, POST))
|
||||
import Text.Blaze.Html (Html, toHtml)
|
||||
import Yesod.Auth (requireAuthId, maybeAuthId)
|
||||
|
@ -80,7 +79,7 @@ import Yesod.Form.Types (FormResult (..))
|
|||
import Yesod.Persist.Core (runDB, get404, getBy404)
|
||||
|
||||
import qualified Data.Text as T (filter, intercalate, pack)
|
||||
import qualified Database.Esqueleto as E ((==.))
|
||||
import qualified Database.Esqueleto as E
|
||||
|
||||
import Database.Persist.Sql.Graph.TransitiveReduction (trrFix)
|
||||
import Yesod.Hashids
|
||||
|
@ -121,7 +120,7 @@ getTicketsR shr prj = do
|
|||
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
||||
getTicketSummaries
|
||||
(filterTickets tf)
|
||||
(Just $ \ t -> [asc $ t ^. TicketNumber])
|
||||
(Just $ \ t -> [E.asc $ t E.^. TicketNumber])
|
||||
jid
|
||||
defaultLayout $(widgetFile "ticket/list")
|
||||
|
||||
|
@ -232,13 +231,13 @@ getTicketR shar proj num = do
|
|||
_ -> return author
|
||||
tparams <- getTicketTextParams tid wid
|
||||
eparams <- getTicketEnumParams tid wid
|
||||
deps <- select $ from $ \ (dep `InnerJoin` t) -> do
|
||||
on $ dep ^. TicketDependencyChild ==. t ^. TicketId
|
||||
where_ $ dep ^. TicketDependencyParent ==. val tid
|
||||
deps <- E.select $ E.from $ \ (dep `E.InnerJoin` t) -> do
|
||||
E.on $ dep E.^. TicketDependencyChild E.==. t E.^. TicketId
|
||||
E.where_ $ dep E.^. TicketDependencyParent E.==. E.val tid
|
||||
return t
|
||||
rdeps <- select $ from $ \ (dep `InnerJoin` t) -> do
|
||||
on $ dep ^. TicketDependencyParent ==. t ^. TicketId
|
||||
where_ $ dep ^. TicketDependencyChild ==. val tid
|
||||
rdeps <- E.select $ E.from $ \ (dep `E.InnerJoin` t) -> do
|
||||
E.on $ dep E.^. TicketDependencyParent E.==. t E.^. TicketId
|
||||
E.where_ $ dep E.^. TicketDependencyChild E.==. E.val tid
|
||||
return t
|
||||
return
|
||||
( wshr, wfl
|
||||
|
@ -538,19 +537,19 @@ postTicketUnassignR shr prj num = do
|
|||
getClaimRequestsPersonR :: Handler Html
|
||||
getClaimRequestsPersonR = do
|
||||
pid <- requireAuthId
|
||||
rqs <- runDB $ select $ from $
|
||||
\ (tcr `InnerJoin` ticket `InnerJoin` project `InnerJoin` sharer) -> do
|
||||
on $ project ^. ProjectSharer ==. sharer ^. SharerId
|
||||
on $ ticket ^. TicketProject ==. project ^. ProjectId
|
||||
on $ tcr ^. TicketClaimRequestTicket ==. ticket ^. TicketId
|
||||
where_ $ tcr ^. TicketClaimRequestPerson ==. val pid
|
||||
orderBy [desc $ tcr ^. TicketClaimRequestCreated]
|
||||
rqs <- runDB $ E.select $ E.from $
|
||||
\ (tcr `E.InnerJoin` ticket `E.InnerJoin` project `E.InnerJoin` sharer) -> do
|
||||
E.on $ project E.^. ProjectSharer E.==. sharer E.^. SharerId
|
||||
E.on $ ticket E.^. TicketProject E.==. project E.^. ProjectId
|
||||
E.on $ tcr E.^. TicketClaimRequestTicket E.==. ticket E.^. TicketId
|
||||
E.where_ $ tcr E.^. TicketClaimRequestPerson E.==. E.val pid
|
||||
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
||||
return
|
||||
( sharer ^. SharerIdent
|
||||
, project ^. ProjectIdent
|
||||
, ticket ^. TicketNumber
|
||||
, ticket ^. TicketTitle
|
||||
, tcr ^. TicketClaimRequestCreated
|
||||
( sharer E.^. SharerIdent
|
||||
, project E.^. ProjectIdent
|
||||
, ticket E.^. TicketNumber
|
||||
, ticket E.^. TicketTitle
|
||||
, tcr E.^. TicketClaimRequestCreated
|
||||
)
|
||||
defaultLayout $(widgetFile "person/claim-requests")
|
||||
|
||||
|
@ -560,22 +559,22 @@ getClaimRequestsProjectR shr prj = do
|
|||
rqs <- runDB $ do
|
||||
Entity sid _ <- getBy404 $ UniqueSharer shr
|
||||
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
||||
select $ from $
|
||||
\ ( tcr `InnerJoin`
|
||||
ticket `InnerJoin`
|
||||
person `InnerJoin`
|
||||
E.select $ E.from $
|
||||
\ ( tcr `E.InnerJoin`
|
||||
ticket `E.InnerJoin`
|
||||
person `E.InnerJoin`
|
||||
sharer
|
||||
) -> do
|
||||
on $ person ^. PersonIdent ==. sharer ^. SharerId
|
||||
on $ tcr ^. TicketClaimRequestPerson ==. person ^. PersonId
|
||||
on $ tcr ^. TicketClaimRequestTicket ==. ticket ^. TicketId
|
||||
where_ $ ticket ^. TicketProject ==. val jid
|
||||
orderBy [desc $ tcr ^. TicketClaimRequestCreated]
|
||||
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
||||
E.on $ tcr E.^. TicketClaimRequestPerson E.==. person E.^. PersonId
|
||||
E.on $ tcr E.^. TicketClaimRequestTicket E.==. ticket E.^. TicketId
|
||||
E.where_ $ ticket E.^. TicketProject E.==. E.val jid
|
||||
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
||||
return
|
||||
( sharer
|
||||
, ticket ^. TicketNumber
|
||||
, ticket ^. TicketTitle
|
||||
, tcr ^. TicketClaimRequestCreated
|
||||
, ticket E.^. TicketNumber
|
||||
, ticket E.^. TicketTitle
|
||||
, tcr E.^. TicketClaimRequestCreated
|
||||
)
|
||||
defaultLayout $(widgetFile "project/claim-request/list")
|
||||
|
||||
|
@ -586,11 +585,11 @@ getClaimRequestsTicketR shr prj num = do
|
|||
Entity sid _ <- getBy404 $ UniqueSharer shr
|
||||
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
||||
Entity tid _ <- getBy404 $ UniqueTicket jid num
|
||||
select $ from $ \ (tcr `InnerJoin` person `InnerJoin` sharer) -> do
|
||||
on $ person ^. PersonIdent ==. sharer ^. SharerId
|
||||
on $ tcr ^. TicketClaimRequestPerson ==. person ^. PersonId
|
||||
where_ $ tcr ^. TicketClaimRequestTicket ==. val tid
|
||||
orderBy [desc $ tcr ^. TicketClaimRequestCreated]
|
||||
E.select $ E.from $ \ (tcr `E.InnerJoin` person `E.InnerJoin` sharer) -> do
|
||||
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
||||
E.on $ tcr E.^. TicketClaimRequestPerson E.==. person E.^. PersonId
|
||||
E.where_ $ tcr E.^. TicketClaimRequestTicket E.==. E.val tid
|
||||
E.orderBy [E.desc $ tcr E.^. TicketClaimRequestCreated]
|
||||
return (sharer, tcr)
|
||||
defaultLayout $(widgetFile "ticket/claim-request/list")
|
||||
|
||||
|
@ -699,22 +698,22 @@ getTicketDeps forward shr prj num = do
|
|||
Entity sid _ <- getBy404 $ UniqueSharer shr
|
||||
Entity jid _ <- getBy404 $ UniqueProject prj sid
|
||||
Entity tid _ <- getBy404 $ UniqueTicket jid num
|
||||
select $ from $
|
||||
\ ( td `InnerJoin`
|
||||
ticket `InnerJoin`
|
||||
person `InnerJoin`
|
||||
E.select $ E.from $
|
||||
\ ( td `E.InnerJoin`
|
||||
ticket `E.InnerJoin`
|
||||
person `E.InnerJoin`
|
||||
sharer
|
||||
) -> do
|
||||
on $ person ^. PersonIdent ==. sharer ^. SharerId
|
||||
on $ ticket ^. TicketCreator ==. person ^. PersonId
|
||||
on $ td ^. to' ==. ticket ^. TicketId
|
||||
where_ $ td ^. from' ==. val tid
|
||||
orderBy [asc $ ticket ^. TicketNumber]
|
||||
E.on $ person E.^. PersonIdent E.==. sharer E.^. SharerId
|
||||
E.on $ ticket E.^. TicketCreator E.==. person E.^. PersonId
|
||||
E.on $ td E.^. to' E.==. ticket E.^. TicketId
|
||||
E.where_ $ td E.^. from' E.==. E.val tid
|
||||
E.orderBy [E.asc $ ticket E.^. TicketNumber]
|
||||
return
|
||||
( ticket ^. TicketNumber
|
||||
( ticket E.^. TicketNumber
|
||||
, sharer
|
||||
, ticket ^. TicketTitle
|
||||
, ticket ^. TicketStatus
|
||||
, ticket E.^. TicketTitle
|
||||
, ticket E.^. TicketStatus
|
||||
)
|
||||
defaultLayout $(widgetFile "ticket/dep/list")
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|||
<th>#
|
||||
<th>Title
|
||||
<th>Created on
|
||||
$forall (Value shr, Value prj, Value num, Value title, Value time) <- rqs
|
||||
$forall (E.Value shr, E.Value prj, E.Value num, E.Value title, E.Value time) <- rqs
|
||||
<tr>
|
||||
<td>
|
||||
<a href=@{SharerR shr}>#{shr2text shr}
|
||||
|
|
|
@ -18,7 +18,7 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|||
<th>Opened by
|
||||
<th>#
|
||||
<th>Title
|
||||
$forall (Entity _ sharer, Value num, Value title, Value time) <- rqs
|
||||
$forall (Entity _ sharer, E.Value num, E.Value title, E.Value time) <- rqs
|
||||
<tr>
|
||||
<td>
|
||||
#{showDate time}
|
||||
|
|
|
@ -20,7 +20,7 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|||
<th>Status
|
||||
$if forward
|
||||
<th>Remove dependency
|
||||
$forall (Value number, Entity _ author, Value title, Value status) <- rows
|
||||
$forall (E.Value number, Entity _ author, E.Value title, E.Value status) <- rows
|
||||
<tr>
|
||||
<td>
|
||||
<a href=@{TicketR shr prj number}>#{number}
|
||||
|
|
Loading…
Reference in a new issue