Comments (9)
I have just pushed better unpaginating support and later today I will probably push support for asynchronous requests, which will improve unpaginating further.
(length (ghub-get "/users/tarsius/repos"))
(length (ghub-get "/users/tarsius/repos" '((per_page . 100))))
(length (ghub-get "/users/tarsius/repos" nil :unpaginate t))
(length (ghub-get "/users/tarsius/repos" '((per_page . 4)) :unpaginate t))
(length (ghub-get "/users/tarsius/repos" '((per_page . 4)) :unpaginate 3))
Asynchronous requests will allow controlled unpaginating without the need for global state.
(ghub-get "/users/tarsius/repos" nil
:unpaginate t
:callback (lambda (value _headers _status _args)
(setq my-value value)))
(ghub-get "/users/tarsius/repos" nil
:callback (lambda (value _headers _status args)
(unless (ghub-continue args)
(setq my-value value))))
These two forms are basically equivalent, but the second could be extended to only unpaginate if some condition is met (most likely if not too much time has passed already).
from ghub.
I can try to work on a solution some time next week, but honestly I can't think of anything satisfactory without introducing either
- a dynamic variable set in
ghub-request
that indicates if alink
exists (regardless ofunpaginate
) - some abstracted response to store the link to the next page of responses along with functions
ghub-next-page
(or somesuch) to interact with that abstraction. This would be a breaking change, but it's probably more powerful while maintaining some simplicity.
What are your thoughts?
from ghub.
Sounds like you want to handle this outside of ghub
.
How about allowing ghub-request
's UNPAGINATE
argument to be an integer or even (NUMBER-OF-REQUESTS . ITEMS-PER-REQUEST)
instead?
from ghub.
I'm not against ghub
handling it, but it does strike me as counter to ghub's minimalist goals. Then again, how do you plan to handle this problem in magit? It's worth some thought.
That consideration notwithstanding, there's only one thing needed for controlled pagination -- three for complete control: where to start returning results. IIRC, this is usually controlled by the page
query parameter. The other two are:
- how many objects per page (default determined by API; I think it's 30)
- how many pages to retrieve (default 1)
For the first piece -- the page
piece -- ghub clients can't give meaningful input unless they know where the previous results dropped off. There has to be some returned value -- whether that's dynamic state (which is gross, I agree) or by a formally returned value (which will be a breaking change). While they may exist, I'm not aware of other options
from ghub.
I missed an option -- it is possible (though a duplication of work across clients) to keep track of which page of each resource was last retrieved. That should be possible to do at the ghub+ level, at which point I'd probably opt for cl-structs (blech!).
Unless there's a better way to do it, of course.
Magit will eventually have this problem, too, since many repositories maintain >30 open PRs:
- https://github.com/twbs/bootstrap
- https://github.com/melpa/melpa
- https://github.com/rust-lang/rfcs
- https://github.com/rust-lang/rust
from ghub.
Does the graphql api also return paginated results?
from ghub.
It does, but it's a little different. GraphQL has a concept of a cursor that it prefers over other methods.
Wondering what you're thinking, here -- as far as ghub is concerned, v4 GraphQL is accessed the same way as v3 REST (I'm pretty sure); see examples.el@b0bd6c
.
from ghub.
While setting a dynamic variable would be an easy fix, I don't think it's the right thing to do -- especially with the impending advent of multithreaded elisp.
from ghub.
thanks!!
from ghub.
Related Issues (20)
- [Document] broken link in magit.vc HOT 4
- Setting up forge tokens using the MacOS keychain auth-source backend HOT 15
- Allow local username configuration HOT 2
- Prompted for 2FA code, yet get error "Must specify two-factor authentication OTP code" HOT 10
- cannot obtain token while 2FA is enabled in Github HOT 1
- Problems using manual token HOT 1
- [FEATURE REQUEST] kanban boards into emacs? HOT 1
- Importance of username case for API authinfo retrieval HOT 5
- The token wizard will break in November HOT 11
- Search for ghub credentials is for the wrong user HOT 1
- cannot use `ghub-continue` to retrieve multiple pages HOT 1
- Documentation typo in section "2.2.4 Setting your Username for Other Hosts and/or Forges"
- error in process filter: BUG: missing headers HOT 4
- Always asking for username and token when using authinfo.gpg with 2-way authentication HOT 33
- 28.0.50: (wrong-type-argument stringp nil) when trying to set github.user HOT 1
- Dead link to Gitlab Tokens in documentation HOT 1
- Unable to use regenerated GitHub token HOT 3
- Unable to download issues from Gitlab HOT 2
- No longer builds with `package-build` from master HOT 2
- Error installing (via melpa w/r/t forge) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghub.