Skip to content

Commit

Permalink
[#500] Trails: Refactor the DB operation expression.
Browse files Browse the repository at this point in the history
This recommendation was made in code review.
a-stacey committed Aug 26, 2019
1 parent 53c869b commit e279717
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions projects/trails/src/Mirza/Trails/Handlers/Trails.hs
Original file line number Diff line number Diff line change
@@ -34,24 +34,19 @@ import Data.Time.Clock
getTrailByEventId :: ( Member context '[HasEnvType, HasConnPool, HasKatipContext, HasKatipLogEnv]
, Member err '[AsTrailsServiceError, AsSqlError])
=> EventId -> AppM context err [TrailEntry]
getTrailByEventId eventId = do
runDb $ (getTrailByEventIdQuery eventId)
getTrailByEventId = runDb . getTrailByEventIdQuery


getTrailBySignature :: ( Member context '[HasEnvType, HasConnPool, HasKatipContext, HasKatipLogEnv]
, Member err '[AsTrailsServiceError, AsSqlError])
=> SignaturePlaceholder -> AppM context err [TrailEntry]
getTrailBySignature sig = do
runDb $ (getTrailBySignatureQuery [] sig)
getTrailBySignature = runDb . getTrailBySignatureQuery []


addTrail :: ( Member context '[HasEnvType, HasConnPool, HasKatipContext, HasKatipLogEnv]
, Member err '[AsTrailsServiceError, AsSqlError])
=> [TrailEntry] -> AppM context err NoContent
addTrail trail = do
_ <- runDb $ (addEntryQuery trail)
pure NoContent

addTrail trail = NoContent <$ (runDb $ addEntryQuery trail)


getTrailByEventIdQuery :: (AsTrailsServiceError err)

0 comments on commit e279717

Please sign in to comment.