feat: topics and list for org #1

Merged
zacheryprenovost merged 3 commits from topics-and-list-for-org into main 2023-11-27 22:00:56 +00:00
2 changed files with 20 additions and 19 deletions
Showing only changes of commit 8c3016e020 - Show all commits

View File

@ -41,22 +41,24 @@ get u r = do
Error.tryGetRepJSON rep
listForOrg :: forall m. MonadAff m => MonadRec m => OrgName -> GiteaT m (Array (Record Repo))
listForOrg o = let
listForOrg o =
let
limit = 10
paginate (repos /\ pageN) =
do
newRepos <- getPage pageN
pure if Array.length newRepos < limit then
pure
if Array.length newRepos < limit then
Done $ repos <> newRepos
else
Loop $ (repos <> newRepos) /\ (pageN + 1)
getPage n = do
{ auth } <- ask
url <- orgReposURL o
url <- orgReposURL o { limit, page: n }
rep <- HTTP.fetch $ HTTP.GET /\ url /\ Auth.headers auth
Error.tryGetRepJSON rep
in tailRecM paginate ([] /\ 1)
in
tailRecM paginate ([] /\ 1)
update
:: forall m patch

View File

@ -42,7 +42,6 @@ derive newtype instance Monad m => MonadError Gitea.Error.Error (GiteaT m)
derive newtype instance Monad m => MonadThrow Gitea.Error.Error (GiteaT m)
derive newtype instance MonadRec m => MonadRec (GiteaT m)
derive newtype instance Monad m => Functor (GiteaT m)
derive newtype instance Monad m => Apply (GiteaT m)
derive newtype instance Monad m => Applicative (GiteaT m)