Skip to content

Commit

Permalink
Fix: all builds
Browse files Browse the repository at this point in the history
  • Loading branch information
matsubara0507 committed Apr 8, 2019
1 parent 6e4e326 commit c781ee6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Git/Plantation/API/CRUD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ getScores = do
fetchBuilds :: Drone.Client c => c -> Problem -> Plant (Text, [Drone.Build])
fetchBuilds client problem = do
let (owner, repo) = splitRepoName $ problem ^. #repo
builds <- tryAny (runReq def $ Drone.getBuilds client owner repo Nothing) >>= \case
Left err -> logError (display err) >> pure []
Right resp -> pure $ responseBody resp
builds <- tryAny (getAllBuilds client owner repo) >>= \case
Left err -> logError (display err) >> pure []
Right builds -> pure builds
pure (problem ^. #name, builds)

getAllBuilds :: (MonadIO m, Drone.Client c) => c -> Text -> Text -> m [Drone.Build]
getAllBuilds client owner repo = mconcat <$> getAllBuilds' [] 1
where
getAllBuilds' xss n = do
resp <- runReq def $ Drone.getBuilds client owner repo (Just n)
case responseBody resp of
[] -> pure xss
builds -> getAllBuilds' (builds : xss) (n + 1)

mkScore :: [Problem] -> Map Text [Drone.Build] -> Team -> Score
mkScore problems builds team
= #team @= team ^. #name
Expand Down

0 comments on commit c781ee6

Please sign in to comment.