Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
[DEVOPS-1039] Filter statuses for success/fail before writing to infl…
Browse files Browse the repository at this point in the history
…uxdb
  • Loading branch information
disassembler committed Sep 17, 2018
1 parent 554c4cf commit d368f39
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions github-webhook-util/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,25 @@ processStatuses (nameCommit, AccumulatorValue _commit statuses firstCreatedAt) =
("commit", Key $ GH.untagName nameCommit)
--, ("pr", Key $ tshow prnum)
]
filteredStatuses = V.filter statusIsSuccessOrFail statuses
fields :: [ ( Key, LineField ) ]
fields = V.toList $ V.map (statusToField time) statuses
fields = V.toList $ V.map (statusToField time) filteredStatuses
entry = Line measurement
(Map.fromList tags)
(Map.fromList fields)
time
if V.length statuses > 0 then
if V.length filteredStatuses > 0 then
write (writeParams database) entry
else
pure ()

statusIsSuccessOrFail :: GH.Status -> Bool
statusIsSuccessOrFail status =
case GH.statusState status of
GH.StatusSuccess -> True
GH.StatusFailure -> True
_ -> False

statusToField :: Maybe UTCTime -> GH.Status -> (Key, LineField)
statusToField createdAt status = statusField
where
Expand Down

0 comments on commit d368f39

Please sign in to comment.