From 5d83206d4f9cfbca4b0a07f45e741ee88b9beca3 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 12 Aug 2024 14:17:59 +0200 Subject: [PATCH] feat: add support to filter by assignee --- src/jira.ts | 8 ++++++-- src/main.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/jira.ts b/src/jira.ts index 03f3cdf..5ee677e 100644 --- a/src/jira.ts +++ b/src/jira.ts @@ -47,9 +47,13 @@ export class Jira { return response.issues ?? raise('Jira.getIssuesByID(): missing issues.'); } - async getIssues(component: string) { + async getIssues(component: string, assignee?: string) { + const dynamicQuery = assignee + ? `component = ${component} AND assignee = "${assignee}"` + : `component = ${component}`; + const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({ - jql: `${this.baseJQL} AND component = ${component} ORDER BY id DESC`, + jql: `${this.baseJQL} AND ${dynamicQuery} ORDER BY id DESC`, fields: [ 'id', 'issuetype', diff --git a/src/main.ts b/src/main.ts index bc4aa0c..802960e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -61,7 +61,7 @@ const cli = async () => { const issues = args.length > 0 ? await jira.getIssuesByID(args) - : await jira.getIssues(options.component); + : await jira.getIssues(options.component, options.assignee); const numberOfIssues = issues.length;