Skip to content

Commit

Permalink
fix: remove extra spaces from jql query
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Oct 8, 2024
1 parent 0af9253 commit 28e0bd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export class Jira {
developer: string | undefined,
customJQL: string | undefined
) {
const componentQuery = component ? `AND component = ${component}` : '';
const assigneeQuery = assignee ? `AND assignee = "${assignee}"` : '';
const developerQuery = developer ? `AND developer = "${developer}"` : '';
const customJQLQuery = customJQL ? `AND ${customJQL}` : '';

this.JQL = `${this.baseJQL} ${customJQLQuery} ${componentQuery} ${assigneeQuery} ${developerQuery} ORDER BY id DESC`;
this.JQL = this.baseJQL;
this.JQL += customJQL ? ` AND ${customJQL}` : '';
this.JQL += component ? ` AND component = ${component}` : '';
this.JQL += assignee ? ` AND assignee = "${assignee}"` : '';
this.JQL += developer ? ` AND developer = "${developer}"` : '';
this.JQL += ' ORDER BY id DESC';

const response = await this.api.issueSearch.searchForIssuesUsingJqlPost({
jql: this.JQL,
Expand Down
12 changes: 6 additions & 6 deletions test/unit/jira.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed ORDER BY id DESC"`
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed ORDER BY id DESC"`
);
expect(mocks.searchForIssuesUsingJqlPost).toHaveBeenCalledWith({
fields: [
Expand All @@ -183,7 +183,7 @@ describe('Jira functions', () => {
'customfield_12310243',
'priority',
],
jql: '("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed ORDER BY id DESC',
jql: '("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed ORDER BY id DESC',
});
expect(issues).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Jira functions', () => {

issues = await jira.getIssues('component', undefined, undefined, undefined);
expect(jira.JQL).toMatchInlineSnapshot(
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component ORDER BY id DESC"`
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component ORDER BY id DESC"`
);

issues = await jira.getIssues(
Expand All @@ -240,7 +240,7 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component AND assignee = "assignee" ORDER BY id DESC"`
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component AND assignee = "assignee" ORDER BY id DESC"`
);

issues = await jira.getIssues(
Expand All @@ -250,12 +250,12 @@ describe('Jira functions', () => {
undefined
);
expect(jira.JQL).toMatchInlineSnapshot(
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component AND assignee = "assignee" AND developer = "developer" ORDER BY id DESC"`
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND component = component AND assignee = "assignee" AND developer = "developer" ORDER BY id DESC"`
);

issues = await jira.getIssues(undefined, undefined, undefined, 'customJQL');
expect(jira.JQL).toMatchInlineSnapshot(
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND customJQL ORDER BY id DESC"`
`"("Story Points" is EMPTY OR priority is EMPTY) AND status != Closed AND customJQL ORDER BY id DESC"`
);
});

Expand Down

0 comments on commit 28e0bd8

Please sign in to comment.