Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to filter issues by developer #16

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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
```

Expand All @@ -79,7 +80,7 @@ Options:

Size all issues of the `curl` component:

```bash
```md
storypointer -c curl
# output:
JIRA Version: 9.12.10
Expand All @@ -95,6 +96,9 @@ Add new feature to curl
5
8
13
---
SKIP
EXIT
```

You can use the arrow keys to select the story points and press `Enter` to confirm. Then you can select the priority. You can exit the tool by pressing `Ctrl+C` or selecting the `Exit` option.
11 changes: 8 additions & 3 deletions src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@
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
) {

Check warning on line 54 in src/jira.ts

View check run for this annotation

Codecov / codecov/patch

src/jira.ts#L50-L54

Added lines #L50 - L54 were not covered by tests
const componentQuery = component ? `AND component = ${component}` : '';
const assigneeQuery = assignee ? `AND assignee = "${assignee}"` : '';
const developerQuery = developer ? `AND developer = "${developer}"` : '';

Check warning on line 57 in src/jira.ts

View check run for this annotation

Codecov / codecov/patch

src/jira.ts#L56-L57

Added lines #L56 - L57 were not covered by tests

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`,

Check warning on line 60 in src/jira.ts

View check run for this annotation

Codecov / codecov/patch

src/jira.ts#L60

Added line #L60 was not covered by tests
fields: [
'id',
'issuetype',
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

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');

Check warning on line 43 in src/main.ts

View check run for this annotation

Codecov / codecov/patch

src/main.ts#L42-L43

Added lines #L42 - L43 were not covered by tests

program.argument('[string]', 'Issue keys separated by `␣`');

Expand All @@ -61,7 +62,11 @@
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
);

Check warning on line 69 in src/main.ts

View check run for this annotation

Codecov / codecov/patch

src/main.ts#L65-L69

Added lines #L65 - L69 were not covered by tests

const numberOfIssues = issues.length;

Expand Down