Skip to content

Commit b273508

Browse files
committed
feat: add support for searching by AssignedTeam
1 parent 71f8f8d commit b273508

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ JIRA_API_TOKEN="exaple-token"
4242
> # ~/.config/storypointer/.env
4343
> ASSIGNEE="your-jira-username"
4444
> DEVELOPER="your-jira-username"
45+
> TEAM="your-jira-team"
4546
> COMPONENT="your-component"
4647
> JQL="your-jql-query"
4748
> ```
@@ -81,6 +82,7 @@ Options:
8182
-c, --component [component] Issue component, use `!` to exclude component
8283
-a, --assignee [assignee] Issue assignee, use `!` to exclude assignee (default: "<user-login>@redhat.com")
8384
-d, --developer [developer] Issue developer, use `!` to exclude developer
85+
-t, --team [team] Issue AssignedTeam, use `!` to exclude team
8486
-j, --jql [jql] JQL query
8587
-l, --legend Print legend
8688
-n, --nocolor Disable color output (default: false)

src/cli.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export function cli(): Command {
4949
'Issue developer, use `!` to exclude developer',
5050
getDefaultValue('DEVELOPER')
5151
)
52+
.option(
53+
'-t, --team [team]',
54+
'Issue AssignedTeam, use `!` to exclude team',
55+
getDefaultValue('TEAM')
56+
)
5257
.option('-j, --jql [jql]', 'JQL query', getDefaultValue('JQL'))
5358
.option('-l, --legend', 'Print legend')
5459
.option(
@@ -92,6 +97,7 @@ const runProgram = async () => {
9297
options.component,
9398
options.assignee,
9499
options.developer,
100+
options.team,
95101
options.jql
96102
);
97103

src/jira.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ export class Jira {
5858
component: string | undefined,
5959
assignee: string | undefined,
6060
developer: string | undefined,
61+
team: string | undefined,
6162
customJQL: string | undefined
6263
) {
6364
this.JQL = this.baseJQL;
6465
this.JQL += customJQL ? ` AND ${customJQL}` : '';
6566
this.JQL += this.composeOptionsJQL('component', component);
6667
this.JQL += this.composeOptionsJQL('assignee', assignee);
6768
this.JQL += this.composeOptionsJQL('developer', developer);
69+
this.JQL += this.composeOptionsJQL('AssignedTeam', team);
6870
this.JQL += ' ORDER BY id DESC';
6971

7072
const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function isDefaultValuesDisabled(): boolean {
2121
}
2222

2323
export function getDefaultValue(
24-
envName: 'ASSIGNEE' | 'COMPONENT' | 'DEVELOPER' | 'JQL' | 'NOCOLOR'
24+
envName: 'ASSIGNEE' | 'COMPONENT' | 'DEVELOPER' | 'TEAM' | 'JQL' | 'NOCOLOR'
2525
) {
2626
if (isDefaultValuesDisabled()) {
2727
return undefined;

test/unit/cli.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('CLI functions', () => {
6262
-a, --assignee [assignee] Issue assignee, use \`!\` to exclude assignee
6363
(default: "username@redhat.com")
6464
-d, --developer [developer] Issue developer, use \`!\` to exclude developer
65+
-t, --team [team] Issue AssignedTeam, use \`!\` to exclude team
6566
-j, --jql [jql] JQL query
6667
-l, --legend Print legend
6768
-n, --nocolor Disable color output (default: false)

test/unit/jira.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ describe('Jira functions', () => {
169169
undefined,
170170
undefined,
171171
undefined,
172+
undefined,
172173
undefined
173174
);
174175
expect(jira.JQL).toMatchInlineSnapshot(
@@ -230,7 +231,13 @@ describe('Jira functions', () => {
230231
]
231232
`);
232233

233-
issues = await jira.getIssues('component', undefined, undefined, undefined);
234+
issues = await jira.getIssues(
235+
'component',
236+
undefined,
237+
undefined,
238+
undefined,
239+
undefined
240+
);
234241
expect(jira.JQL).toMatchInlineSnapshot(
235242
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = "component" ORDER BY id DESC"`
236243
);
@@ -239,6 +246,7 @@ describe('Jira functions', () => {
239246
'component',
240247
'assignee',
241248
undefined,
249+
undefined,
242250
undefined
243251
);
244252
expect(jira.JQL).toMatchInlineSnapshot(
@@ -249,13 +257,20 @@ describe('Jira functions', () => {
249257
'component',
250258
'assignee',
251259
'developer',
260+
'team',
252261
undefined
253262
);
254263
expect(jira.JQL).toMatchInlineSnapshot(
255-
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = "component" AND assignee = "assignee" AND developer = "developer" ORDER BY id DESC"`
264+
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND component = "component" AND assignee = "assignee" AND developer = "developer" AND AssignedTeam = "team" ORDER BY id DESC"`
256265
);
257266

258-
issues = await jira.getIssues(undefined, undefined, undefined, 'customJQL');
267+
issues = await jira.getIssues(
268+
undefined,
269+
undefined,
270+
undefined,
271+
undefined,
272+
'customJQL'
273+
);
259274
expect(jira.JQL).toMatchInlineSnapshot(
260275
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND customJQL ORDER BY id DESC"`
261276
);
@@ -264,10 +279,11 @@ describe('Jira functions', () => {
264279
undefined,
265280
'!assignee',
266281
'developer',
282+
'!team',
267283
'customJQL'
268284
);
269285
expect(jira.JQL).toMatchInlineSnapshot(
270-
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND customJQL AND assignee != "assignee" AND developer = "developer" ORDER BY id DESC"`
286+
`"Project = RHEL AND (type in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY) OR type not in (Story, Task) AND ("Story Points" is EMPTY OR priority is EMPTY OR Severity is EMPTY)) AND status != Closed AND customJQL AND assignee != "assignee" AND developer = "developer" AND AssignedTeam != "team" ORDER BY id DESC"`
271287
);
272288
});
273289

0 commit comments

Comments
 (0)