Skip to content

Commit

Permalink
Merge pull request #93 from mattpolzin/add-link-to-health-graph
Browse files Browse the repository at this point in the history
Add link to GH at bottom of health graph.
  • Loading branch information
mattpolzin authored Nov 20, 2023
2 parents fc9ebb6 + 27458bf commit f26f35f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Commands.idr
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ graph @{config} args = do
export
health : Config => Octokit =>
Promise ()
health = do
health @{config} = do
prs <- listOpenPRs {pageBreaks = 4} 100
renderIO $ healthGraph prs
renderIO $ healthGraph prs config.org config.repo

(<||>) : Alternative t => (a -> t b) -> (a -> t b) -> a -> t b
(<||>) f g x = f x <|> g x
Expand Down
10 changes: 9 additions & 1 deletion src/Graph.idr
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,22 @@ graph highScore = vsep . map (graphOne highScore)
||| Produce a graph of open pull requests per month (by the month the PR was created).
export
healthGraph : (openPullRequests : List PullRequest)
-> (org : String)
-> (repo : String)
-> Doc AnsiStyle
healthGraph openPullRequests =
healthGraph openPullRequests org repo =
let groups = groupBy ((==) `on` .month `on` .createdAt) $ sortBy (compare `on` .createdAt) openPullRequests
max = foldr (\xs,m => max (length xs) m) 1 groups
in vsep [ header
, graph max (unfoldGraph (limit 48) groups Nothing)
, emptyDoc
, pretty link
, emptyDoc
]
where
link : String
link = "https://github.com/\{org}/\{repo}/pulls?q=is%3Apr+is%3Aopen+sort%3Acreated-asc"

graphable : (List1 PullRequest) -> PRsOnDate Date
graphable (pr ::: tail) = MkPRsOnDate pr.createdAt (S $ length tail)

Expand Down

0 comments on commit f26f35f

Please sign in to comment.