From 350459d8aeae3b75a82886b4a40e8ed3c26eeccc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Mar 2025 16:15:43 +0100 Subject: [PATCH 1/3] added maxResult key for search request of jira client --- .../context/providers/JiraIssuesContextProvider/JiraClient.ts | 4 +++- core/context/providers/JiraIssuesContextProvider/index.ts | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts index 9a83d279d..0079ea5c6 100644 --- a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts +++ b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts @@ -9,6 +9,7 @@ interface JiraClientOptions { password: string; issueQuery?: string; apiVersion?: string; + maxResults?: string; requestOptions?: RequestOptions; } @@ -73,6 +74,7 @@ export class JiraClient { "assignee = currentUser() AND resolution = Unresolved order by updated DESC", apiVersion: "3", requestOptions: {}, + maxResults: "50", ...options, }; this.baseUrl = `https://${this.options.domain}/rest/api/${this.options.apiVersion}`; @@ -146,7 +148,7 @@ export class JiraClient { `/search?fields=summary&jql=${ this.options.issueQuery ?? "assignee = currentUser() AND resolution = Unresolved order by updated DESC" - }`, + }&maxResults=${this.options.maxResults}`, ), { method: "GET", diff --git a/core/context/providers/JiraIssuesContextProvider/index.ts b/core/context/providers/JiraIssuesContextProvider/index.ts index d13022140..35a14aba4 100644 --- a/core/context/providers/JiraIssuesContextProvider/index.ts +++ b/core/context/providers/JiraIssuesContextProvider/index.ts @@ -25,6 +25,7 @@ class JiraIssuesContextProvider extends BaseContextProvider { issueQuery: this.options.issueQuery, apiVersion: this.options.apiVersion, requestOptions: this.options.requestOptions, + maxResults: this.options.maxResults }); } @@ -32,8 +33,6 @@ class JiraIssuesContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { - const issueId = query; - const api = this.getApi(); const issue = await api.issue(query, extras.fetch); From e648af76aa470ea04eda6723896ca416ae09a61f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Mar 2025 16:35:56 +0100 Subject: [PATCH 2/3] handle the case if maxResult parameter is undefined --- core/context/providers/JiraIssuesContextProvider/JiraClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts index 0079ea5c6..966fa47f5 100644 --- a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts +++ b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts @@ -148,7 +148,7 @@ export class JiraClient { `/search?fields=summary&jql=${ this.options.issueQuery ?? "assignee = currentUser() AND resolution = Unresolved order by updated DESC" - }&maxResults=${this.options.maxResults}`, + }&maxResults=${this.options.maxResults ?? "50"}`, ), { method: "GET", From e05ef9b200b6df1f45fefe3e86825ba7e20164e0 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Mar 2025 16:41:02 +0100 Subject: [PATCH 3/3] added documentation for maxResult --- docs/docs/customize/context-providers.mdx | 5 +++++ extensions/vscode/config_schema.json | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/docs/docs/customize/context-providers.mdx b/docs/docs/customize/context-providers.mdx index 41c6edc57..b31deedf4 100644 --- a/docs/docs/customize/context-providers.mdx +++ b/docs/docs/customize/context-providers.mdx @@ -879,6 +879,11 @@ assignee = currentUser() AND resolution = Unresolved order by updated DESC You can override this query by setting the `issueQuery` parameter. +#### Max results + +You can set the `maxResults` parameter to limit the number of results returned. The default is `50`. + + ### `@Discord` Reference the messages in a Discord channel. diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index bf83c1234..78d73320d 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2329,6 +2329,10 @@ "type": "string", "description": "Customize the query used to find Jira issues" }, + "maxResults": { + "type": "string", + "description": "The maximum number of issues that will be returned. Defaults to 50." + }, "apiVersion": { "type": "integer", "markdownDescription": "This context provider supports both Jira API version 2 and 3. It will use version 3 by default since that's what the cloud version uses, but if you have the datacenter version of Jira, you'll need to set the API Version to 2 using the `apiVersion` property.",