From f72855ea8ade8f94474618c5dacda8dd30171740 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 20 Mar 2022 19:02:06 +0100 Subject: server: keep (one) last good result per repo (i.e. we want to still have a valid version of the map if new results where introduced) --- server/Handlers.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/Handlers.hs') diff --git a/server/Handlers.hs b/server/Handlers.hs index 0e30d2f..987b6df 100644 --- a/server/Handlers.hs +++ b/server/Handlers.hs @@ -52,9 +52,9 @@ instance ToJSON MapService where . mapMaybe worldObject $ M.elems statuses where - worldObject (RemoteRef {..}, job) = case job of - Linted res rev _ -> - Just (A.fromText reponame .= + worldObject (remote, _current, result) = case result of + Just (Linted res rev _) -> + Just (A.fromText (reponame remote) .= M.mapWithKey (mapInfo rev) (dirresultMaps res)) _ -> Nothing mapInfo rev mappath MapResult { .. } = A.object @@ -68,8 +68,8 @@ statusImpl :: MVar ServerState -> Text -> Sha1 -> Handler JobStatus statusImpl state orgslug sha1 = do status <- liftIO $ getJobStatus state orgslug sha1 case status of - Just (_,_,jobstatus) -> pure jobstatus - Nothing -> throwError err404 + Just (_,_,jobstatus,_) -> pure jobstatus + Nothing -> throwError err404 -- | since there are multiple apis that just get state information … stateImpl @@ -83,7 +83,7 @@ relintImpl :: TQueue Job -> MVar ServerState -> Text -> Sha1 -> Handler Text relintImpl queue state orgslug sha1 = liftIO $ getJobStatus state orgslug sha1 >>= \case Nothing -> pure "there isn't a job here to restart" - Just (org, ref, _oldjob) -> do + Just (org, ref, _oldjob, _veryoldjob) -> do atomically $ writeTQueue queue (Job ref org) pure "hello" @@ -91,7 +91,7 @@ relintImpl queue state orgslug sha1 = realtimeImpl :: MVar ServerState -> Text -> Sha1 -> PendingConnection -> Handler () realtimeImpl state orgslug sha1 pending = liftIO (getJobStatus state orgslug sha1) >>= \case - Just (_org, _ref, Linted _ _ (_, realtime)) -> do + Just (_org, _ref, Linted _ _ (_, realtime), _) -> do conn <- liftIO $ acceptRequest pending incoming <- atomically $ dupTChan realtime liftIO $ withPingThread conn 30 pass $ forever $ do -- cgit v1.2.3