From cfd1fc531b1ce417b1518711f5236d6606b6c73a Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 1 Feb 2020 16:23:02 +0100 Subject: [PATCH] Speed up getForks by using search API --- lib/GHup.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/GHup.hs b/lib/GHup.hs index 89ef60d..45a5772 100644 --- a/lib/GHup.hs +++ b/lib/GHup.hs @@ -60,6 +60,8 @@ import GitHub.Data.Name import GitHub.Data.URL import GitHub.Data.Request import GitHub.Endpoints.Repos +import GitHub.Endpoints.Search +import GitHub.Endpoints.Users import GitHub.Request import HPath import HPath.IO @@ -326,14 +328,17 @@ getForks :: (MonadIO m, MonadReader Settings m) => Maybe UTCTime -> ExceptT Error m [Repo] getForks mtime = do - repos <- githubAuth (currentUserReposR RepoPublicityAll FetchAll) + user <- githubAuth userInfoCurrentR + let userName = untagName $ userLogin user + repos <- github_ + (searchReposR $ mconcat [T.pack "user:", userName, T.pack " fork:only"]) pure $ sortBy (\x y -> compare (repoUpdatedAt y) (repoUpdatedAt x)) $ filter (\case Repo { repoFork = Just True, repoUpdatedAt = Just t } -> maybe True (t >=) mtime _ -> False ) - (toList repos) + (toList $ searchResultResults repos)