summaryrefslogtreecommitdiff
path: root/Biz/Devalloc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Devalloc.hs')
-rw-r--r--Biz/Devalloc.hs55
1 files changed, 29 insertions, 26 deletions
diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs
index acbb606..df90c9e 100644
--- a/Biz/Devalloc.hs
+++ b/Biz/Devalloc.hs
@@ -1101,8 +1101,8 @@ instance Lucid.ToHtml Analysis where
Lucid.h3_ "Total score:"
Lucid.p_ <| Lucid.toHtml <| Text.pack <| show score
Lucid.h3_ "Active authors:"
- Lucid.p_ <| forM_ activeAuthors <| \author -> do
- Lucid.toHtml author
+ Lucid.ul_ <| forM_ activeAuthors <| \author -> do
+ Lucid.li_ <| Lucid.toHtml author
Lucid.h3_ <| Lucid.toHtml <| "Total files: " <> tshow totalFiles
Lucid.h3_ <| Lucid.toHtml <| "Found " <> slen blackholes <> " blackholes:"
Lucid.ul_ <| do
@@ -1269,9 +1269,7 @@ analyzeGitHub ::
IO Analysis
analyzeGitHub keep User {..} depo o r = do
activeAuthors <-
- GitHub.collaboratorsOnR ghOwner ghRepo GitHub.FetchAll
- |> GitHub.github ghAuth
- +> either getTopContributors (identity .> pure)
+ getPeople
/> Vector.map (GitHub.simpleUserLogin .> GitHub.userInfoForR)
/> Vector.toList
+> Async.mapConcurrently (GitHub.github ghAuth)
@@ -1288,27 +1286,32 @@ analyzeGitHub keep User {..} depo o r = do
ghOwner = GitHub.mkName (Proxy :: Proxy GitHub.Owner) o
ghRepo = GitHub.mkName (Proxy :: Proxy GitHub.Repo) r
- getTopContributors :: GitHub.Error -> IO (Vector GitHub.SimpleUser)
- getTopContributors = \case
- GitHub.ParseError err -> panic err
- GitHub.JsonError err -> panic err
- GitHub.UserError err -> panic err
- GitHub.HTTPError ex -> do
- Log.warn ["getTopContributors", tshow ex]
- -- TODO: match 'ex' on specific 403 error?
- -- TODO: get contributors, return top 10%
- -- 'False' means don't include anonymous contributors
- GitHub.contributorsR ghOwner ghRepo False GitHub.FetchAll
- |> GitHub.github ghAuth
- /> either (panic <. tshow) identity
- -- TODO: I can't figure out how to use this
- -- /> Vector.sortBy
- -- ( \case
- -- GitHub.KnownContributor n _ _ _ _ _ -> n
- -- GitHub.AnonymousContributor n _ -> n
- -- )
- /> Vector.take 10
- /> Vector.mapMaybe GitHub.contributorToSimpleUser
+ getPeople :: IO (Vector GitHub.SimpleUser)
+ getPeople =
+ Async.runConcurrently <| (Vector.++)
+ </ Concurrently getCollaborators
+ <*> Concurrently getTopContributors
+
+ getCollaborators :: IO (Vector GitHub.SimpleUser)
+ getCollaborators =
+ GitHub.collaboratorsOnR ghOwner ghRepo GitHub.FetchAll
+ |> GitHub.github ghAuth
+ /> either mempty identity
+
+ getTopContributors :: IO (Vector GitHub.SimpleUser)
+ getTopContributors =
+ -- 'False' means don't include anonymous contributors
+ GitHub.contributorsR ghOwner ghRepo False GitHub.FetchAll
+ |> GitHub.github ghAuth
+ /> either mempty identity
+ -- TODO: return top 10%; I can't figure out how to use this />
+ -- Vector.sortBy
+ -- ( \case
+ -- GitHub.KnownContributor n _ _ _ _ _ -> n
+ -- GitHub.AnonymousContributor n _ -> n
+ -- )
+ /> Vector.take 10
+ /> Vector.mapMaybe GitHub.contributorToSimpleUser
test_analyzeGitHub :: IO (Config, Application, Acid.AcidState Keep) -> Test.Tree
test_analyzeGitHub load =