Speed up getForks by using search API
This commit is contained in:
parent
fe9578c9d6
commit
cfd1fc531b
@ -60,6 +60,8 @@ import GitHub.Data.Name
|
|||||||
import GitHub.Data.URL
|
import GitHub.Data.URL
|
||||||
import GitHub.Data.Request
|
import GitHub.Data.Request
|
||||||
import GitHub.Endpoints.Repos
|
import GitHub.Endpoints.Repos
|
||||||
|
import GitHub.Endpoints.Search
|
||||||
|
import GitHub.Endpoints.Users
|
||||||
import GitHub.Request
|
import GitHub.Request
|
||||||
import HPath
|
import HPath
|
||||||
import HPath.IO
|
import HPath.IO
|
||||||
@ -326,14 +328,17 @@ getForks :: (MonadIO m, MonadReader Settings m)
|
|||||||
=> Maybe UTCTime
|
=> Maybe UTCTime
|
||||||
-> ExceptT Error m [Repo]
|
-> ExceptT Error m [Repo]
|
||||||
getForks mtime = do
|
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
|
pure $ sortBy (\x y -> compare (repoUpdatedAt y) (repoUpdatedAt x)) $ filter
|
||||||
(\case
|
(\case
|
||||||
Repo { repoFork = Just True, repoUpdatedAt = Just t } ->
|
Repo { repoFork = Just True, repoUpdatedAt = Just t } ->
|
||||||
maybe True (t >=) mtime
|
maybe True (t >=) mtime
|
||||||
_ -> False
|
_ -> False
|
||||||
)
|
)
|
||||||
(toList repos)
|
(toList $ searchResultResults repos)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user