Code Monkey home page Code Monkey logo

Comments (14)

ghostsquad avatar ghostsquad commented on June 9, 2024 1

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 PaginatedResult type object, that simply makes it very easy to request the next page.

Some ideas for reference:
https://github.com/qiangxue/golang-restful-starter-kit/blob/master/util/paginated_list.go

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 {
   ...
}

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

Sorry for the late reply @stevegore.
You are right, sophisticated pagination support is not implemented (yet).
At the moment you can reach this feature by applying the StartAt in your SearchOptions in your application code.

This can have pro and cons.
Cons: Every app needs to implement this
Pro: You might not flood your JIRA instance with requests.

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.
Right now i don't have time to implement it myself. Sorry.
Would you mind to give it a try and add this feature?

from go-jira.

github-actions avatar github-actions commented on June 9, 2024

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.

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

After some time, I am against my own comment from 2017.
Pagination should be handled more explicitly.

Happy to accept PRs in this direction.

from go-jira.

fdcds avatar fdcds commented on June 9, 2024

At the moment you can reach this feature by applying the StartAt in your SearchOptions in your application code.

With GetIssuesForSprint I ran into the issue that I do not see a way to specify StartAt (#302).

from go-jira.

github-actions avatar github-actions commented on June 9, 2024

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.

from go-jira.

eparis avatar eparis commented on June 9, 2024

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
}

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

from go-jira.

kp2401075 avatar kp2401075 commented on June 9, 2024

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?

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

Hey @kp2401075,
Adding this as an example would be a good idea.
We aim to keep a fetch all functionality outside of this library. Pagination should be handled by the client/caller.

The library itself should cover attributes like StartAt to enable pagination.
What do you think @kp2401075 ?

from go-jira.

kp2401075 avatar kp2401075 commented on June 9, 2024

@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.

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

I suggest adding a new example with a particular focus on pagination rather than making an existing example more complex.
Another idea would be to add a section to the readme

from go-jira.

eparis avatar eparis commented on June 9, 2024

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!

from go-jira.

andygrunwald avatar andygrunwald commented on June 9, 2024

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.
If you seek priority development for your issue + you like to sponsor it, please contact me.

What does this mean for my issue?

We will work on this issue indirectly.
This means that during the development phase, we aim to tackle it.
Maybe in a different way like it is currently handled.
Please understand that this will take a while because we are running this in our spare time.

Final words

Thanks for using this library.
If there is anything else you would like to tell us, let us know!

from go-jira.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.