-
-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for pagination #55
Comments
Sorry for the late reply @stevegore. This can have pro and cons. Your idea to request this concurrent is quite nice. Thank you for this. If someone would implement this and apply a PR, i would be happy to merge it. |
I would strong advice against automating any sort of "fetch all" functionality, as with the wrong query, this could easily timeout, or fetch more items that can be managed. Instead, I think we could implement a Some ideas for reference: I didn't find much in the way of lazy evaluation in Go, but I suspect it's as simple as returning a function to the caller, which when invoked could fetch the next page. func (p *PaginatedResult) Next() func() *PaginatedResult {
...
} |
This issue has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
After some time, I am against my own comment from 2017. Happy to accept PRs in this direction. |
With |
This issue has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Since I ended up here I figured I'd post this for the next person implementing it in your code.
|
Thanks Eric!
Would you be interested in adding this code as an example via a Pull
Request?
This would be a great addition to the docs.
Eric Paris <[email protected]> schrieb am Mi. 19. Aug. 2020 um 21:59:
…
Since I ended up here I figured I'd post this for the next person
implementing it in your code.
func GetIssues(client *jira.Client, searchString string) ([]jira.Issue, error) {
last := 0
var issues []jira.Issue = nil
for {
opt := &jira.SearchOptions{
MaxResults: 100,
StartAt: last,
}
chunk, resp, err := client.Issue.Search(searchString, opt)
if err != nil {
return nil, err
}
total := resp.Total
if issues == nil {
issues = make([]jira.Issue, 0, total)
}
issues = append(issues, chunk...)
last = resp.StartAt + len(chunk)
if last >= total {
break
}
}
return issues, nil
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#55 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACOEQA7X2VLYESNQYK3YF3SBQVINANCNFSM4CZSHZMA>
.
|
Hey @andygrunwald & @eparis , I would be interested in adding @eparis's code as a pull request only if he is ok with it. and if he is ok @andygrunwald would it go in issue.go? |
Hey @kp2401075, The library itself should cover attributes like StartAt to enable pagination. |
@andygrunwald That sounds good, In that case where do you think should I add examples/jql ? If somewhere else please suggest. BTW, I'm very new to golang so If I do something stupid please point it out. thanks. |
I suggest adding a new example with a particular focus on pagination rather than making an existing example more complex. |
My code snippet above may be used in any context. It is public domain if your jurisdiction allows it. It may also be used under any open source license if a license is required. Go forth and use it! |
Hey, I am very sorry that this issue has been open for a long time with no final solution. We work on this project in our spare time, and sometimes, other priorities take over. This is the typical open source dilemma. However, there is news: We are kicking off v2 of this library 🚀To provide visibility, we created the Road to v2 Milestone and calling for your feedback in #489 The development will take some time; however, I hope you can benefit from the changes. What does this mean for my issue?We will work on this issue indirectly. Final wordsThanks for using this library. |
The JIRA REST API applies pagination to a number of resources (e.g. users in group, issues returned from a search): https://docs.atlassian.com/jira/REST/server/#pagination
Ideally we would fetch the first page, and the fetch other pages concurrently.
Currently, it seems like this needs to be done manually with each implementation of the library.
The text was updated successfully, but these errors were encountered: