gitbeaker icon indicating copy to clipboard operation
gitbeaker copied to clipboard

Ability to search issues?

Open jcroall opened this issue 2 years ago • 4 comments

Description

When using the Issues module, is it possible to pass options to it? E.g. to search title/description ("search") or status like opened/closed/all?

At first I thought I could pass options to Issues.all(), but I can't tell if this is actually just pagination options. It doesn't seem to honor the options I'm passing, which are taken from the GitLab API reference. I thought this might work:

    let issues = await api.Issues.all({
        projectId: project_id,
        options: {
            search: title_search,
            state: "opened"
        }
    })

For a large project the "all" issues could be quite significant and time consuming to filter locally!

Thanks!

Checklist

  • [x] I have checked that this is not a duplicate issue.
  • [x] I have read the documentation.

jcroall avatar Apr 24 '22 16:04 jcroall

Hey!

With the object styled arguments, you don't need to nest them into an options parameter. This should work:

 let issues = await api.Issues.all({
        projectId: project_id,
        search: title_search,
        state: "opened"
    })

jdalrymple avatar Apr 24 '22 17:04 jdalrymple

Hey!

With the object styled arguments, you don't need to nest them into an options parameter. This should work:

 let issues = await api.Issues.all({
        projectId: project_id,
        search: title_search,
        state: "opened"
    })

Thanks! Makes sense, but it still seems to be returning everything. For now I'm post-processing the list, but I worry about scale as projects get larger with longer history.

jcroall avatar Apr 24 '22 18:04 jcroall

100%

If you want to paginate those filtered results, you could add offset pagination settings:

const { data, paginationInfo } = await api.Issues.all({
    projectId: project_id,
    search: title_search,
    state: "opened",
    page:1,
    showExpanded: true
});

Where the response would be in this format:

data: [
...
],
paginationInfo: {
  next: 4,
  current: 2,
  previous: 1,
  perPage: 3,
}

jdalrymple avatar Apr 24 '22 19:04 jdalrymple

Its still a bit rough around the edges and is being revisited in #1702, but it should get the job done as it!

jdalrymple avatar Apr 24 '22 19:04 jdalrymple