summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-02-05 22:58:36 -0500
committerBen Sima <ben@bsima.me>2021-02-05 22:58:36 -0500
commitd264355fcfbed439157eb7ce9371776806bc2253 (patch)
tree47fb87cfabe1d416a763c16ad6abaebf7ff5c346 /Biz
parentfb9d9c6a05e89bfe77cf7fe0735f4ebaeb1e88b4 (diff)
Combine contributors and collaborators
It's easier and cleaner this way - I don't have to do complex switching between the two. Instead just treat them as the same thing basically. Can adjust later if need be.
Diffstat (limited to 'Biz')
-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 =