Recently we implemented a feature on our JIRA (through ScriptRunner) by adding a "Custom web item" button which triggers the execution of a "Custom REST endpoint" so that it can read the query string parameter for the "jql=" value and then generates a static web page which contains "batches", each batch is a hyperlink to download 1000 issues. Something like this:
https://(domain)/sr/jira.issueviews:searchrequest-csv-current-fields/temp/SearchRequest.csv?jqlQuery=(jql-text)&tempMax=1000&pager/start=(page-offset)
It works well when the user explicitly types the JQL text into the search box, because its content will be copied to the browser address box and thus becomes the "jql=" value, like so:
https://(domain)/issues/?jql=(jql-text)
And thus our code can get it from the "jql=" parameter and proceed to produce the web page. If However the user selects from one of the filters, there's no "jql=" parameter, but "filter=" instead, like so:
https://(domain)/issues/?filter=(filter-ID)
Our code can still look up the JQL text string by means of calling this: searchRequestService.getFilter(new JiraServiceContextImpl(user), id).query.queryString
It almost works... At least most of the times, except when the user selects from one of those system default filters such as "My open issues" / "Reported by me", etc. When they are selected (so far 9 of them in total) the ID is always a negative value (from -1 to -9) and when that value is passed to the getFilter(user, id) function, it always returns null.
I have searched for the JIRA API docs:
https://docs.atlassian.com/software/jira/docs/api/7.5.3/overview-summary.html
... and can't seem to find a function or class/interface to deal with matching the negative filter ID to the default system filters. Currently we just do it the hard-coded way, such as mapping "-1" to "assignee = currentUser() AND resolution = Unresolved order by updated DESC" and "-2" to "reporter = currentUser() order by created DESC", etc. But that kind of hard-coding style is a symptom of "code smell", and apparently if JIRA changes the JQL for those default filters (maybe in a future upgrade), our current code needs to change as well (provided we know JIRA has changed it) or else there will be a problem: what user selects is not what our code exports.
So, may I ask if there's any place in JIRA API where I can find a way to query for the JQL text for those default filters? Thanks in advance for any reply you can provide.