generated from tpl/purs
feat: topics and list for org #1
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user