From 4cddbff765970a9e99a4f4734d2dfc59fa6d50c2 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 12 Aug 2024 16:00:05 +0200 Subject: [PATCH] feat: add option to filter issues by developer ``` storypointer -d ``` --- README.md | 5 +++-- src/jira.ts | 11 ++++++++--- src/main.ts | 9 +++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a66c702..f0239a6 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ storypointer > > This tool is intended to be used by Red Hat employees on the Red Hat JIRA instance. It may be adapted to work with other JIRA instances in the future. -```bash +```md $ storypointer --help Usage: storypointer [options] [string] @@ -68,6 +68,7 @@ Options: -V, --version output the version number -c, --component [component] Issue component -a, --assignee [assignee] Issue assignee + -d, --developer [developer] Issue developer -h, --help display help for command ``` @@ -79,7 +80,7 @@ Options: Size all issues of the `curl` component: -```bash +```md storypointer -c curl # output: JIRA Version: 9.12.10 diff --git a/src/jira.ts b/src/jira.ts index 68abff4..9186678 100644 --- a/src/jira.ts +++ b/src/jira.ts @@ -47,12 +47,17 @@ export class Jira { return response.issues ?? raise('Jira.getIssuesByID(): missing issues.'); } - async getIssues(component: string, assignee?: string) { - const assigneeQuery = assignee ? `AND assignee = "${assignee}"` : ''; + async getIssues( + component: string | undefined, + assignee: string | undefined, + developer: string | undefined + ) { const componentQuery = component ? `AND component = ${component}` : ''; + const assigneeQuery = assignee ? `AND assignee = "${assignee}"` : ''; + const developerQuery = developer ? `AND developer = "${developer}"` : ''; const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({ - jql: `${this.baseJQL} ${assigneeQuery} ${componentQuery} ORDER BY id DESC`, + jql: `${this.baseJQL} ${componentQuery} ${assigneeQuery} ${developerQuery} ORDER BY id DESC`, fields: [ 'id', 'issuetype', diff --git a/src/main.ts b/src/main.ts index 94ed00a..0f978f4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,8 @@ const cli = async () => { program .option('-c, --component [component]', 'Issue component') - .option('-a, --assignee [assignee]', 'Issue assignee'); + .option('-a, --assignee [assignee]', 'Issue assignee') + .option('-d, --developer [developer]', 'Issue developer'); program.argument('[string]', 'Issue keys separated by `␣`'); @@ -61,7 +62,11 @@ const cli = async () => { const issues = args.length > 0 ? await jira.getIssuesByID(args) - : await jira.getIssues(options.component, options.assignee); + : await jira.getIssues( + options.component, + options.assignee, + options.developer + ); const numberOfIssues = issues.length;