Skip to content

Commit

Permalink
Treat issue summary targets optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck committed May 1, 2024
1 parent 45c4f63 commit c6bd735
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Fossa/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ data Issues = Issues

data IssuesSummary = IssuesSummary
{ revision :: IssueSummaryRevision
, targets :: Maybe [IssueSummaryTarget]
, targets :: [IssueSummaryTarget]
}
deriving (Eq, Ord, Show)

Expand Down Expand Up @@ -356,7 +356,8 @@ instance FromJSON IssuesSummary where
<$> obj
.: "revision"
<*> obj
.: "targets"
.:? "targets"
.!= []

instance ToJSON IssuesSummary where
toJSON IssuesSummary{..} =
Expand Down Expand Up @@ -739,14 +740,12 @@ renderedIssues issues = rendered
, line
]

renderRevisionTargets :: Maybe [IssueSummaryTarget] -> Doc ann
renderRevisionTargets issueRevisionTargets = case issueRevisionTargets of
Nothing -> mempty
Just [] -> mempty
Just targets ->
vsep $
["Project Targets:"]
<> map (\target -> "- " <> renderedTarget target) (sort targets)
renderRevisionTargets :: [IssueSummaryTarget] -> Doc ann
renderRevisionTargets [] = mempty
renderRevisionTargets targets =
vsep $
["Project Targets:"]
<> map (\target -> "- " <> renderedTarget target) (sort targets)

renderProjectVisibility :: Maybe Bool -> Doc ann
renderProjectVisibility Nothing = "unknown"
Expand Down

0 comments on commit c6bd735

Please sign in to comment.