summaryrefslogtreecommitdiff
path: root/server/Handlers.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/Handlers.hs')
-rw-r--r--server/Handlers.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/server/Handlers.hs b/server/Handlers.hs
index cb714d9..a4ddab4 100644
--- a/server/Handlers.hs
+++ b/server/Handlers.hs
@@ -8,7 +8,7 @@ module Handlers (
-- , relintImpl
, adminOverviewImpl
, AdminOverview(..)
- ) where
+ ,MapService(..)) where
import Universum
@@ -18,7 +18,7 @@ import qualified Data.Aeson as A
import qualified Data.Map as M
import Servant (Handler, err404, throwError)
import Server (JobStatus (..), ServerState, Sha1,
- unState)
+ getJobStatus, unState)
-- | annoying (and afaik unused), but has to be here for type system reasons
-- instance MonadFail Handler where
@@ -48,23 +48,24 @@ import Server (JobStatus (..), ServerState, Sha1,
-- pure NoContent
-- | an info type wrapped around the server state, to carry serialisation instances.
--- TODO: should probably not be defined here
newtype AdminOverview =
AdminOverview { unAdminOverview :: ServerState }
+newtype MapService =
+ MapService { unMapService :: ServerState }
+
instance ToJSON AdminOverview where
toJSON (AdminOverview state) =
- toJSON $ view unState state <&> \(ref, status) ->
+ toJSON $ view unState state <&> \org -> flip map org $ \(ref, status) ->
A.object [ "remote" .= ref
, "status" .= status
]
-statusImpl :: MVar ServerState -> Sha1 -> Handler JobStatus
-statusImpl state sha1 = do
- status <- liftIO $ withMVar state $ \state ->
- pure $ M.lookup sha1 (map snd $ view unState state)
+statusImpl :: MVar ServerState -> Text -> Sha1 -> Handler JobStatus
+statusImpl state orgslug sha1 = do
+ status <- liftIO $ getJobStatus state orgslug sha1
case status of
- Just res -> pure res
+ Just res -> pure $ snd res
Nothing -> throwError err404