From e279717e80f8950c943961f12395def2890585f6 Mon Sep 17 00:00:00 2001 From: Ashley Stacey Date: Tue, 27 Aug 2019 09:46:44 +1000 Subject: [PATCH] [#500] Trails: Refactor the DB operation expression. This recommendation was made in code review. --- projects/trails/src/Mirza/Trails/Handlers/Trails.hs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/projects/trails/src/Mirza/Trails/Handlers/Trails.hs b/projects/trails/src/Mirza/Trails/Handlers/Trails.hs index 2b20ea03..83ae0487 100644 --- a/projects/trails/src/Mirza/Trails/Handlers/Trails.hs +++ b/projects/trails/src/Mirza/Trails/Handlers/Trails.hs @@ -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)