Skip to content

Commit

Permalink
Enhanced Jira integration to support filtering by components in JQL q…
Browse files Browse the repository at this point in the history
…ueries
  • Loading branch information
SaachiNayyer committed Mar 21, 2024
1 parent c108b55 commit 7384a0d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .changeset/famous-readers-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@axis-backstage/plugin-jira-dashboard-backend': major
---

Updated the getIssuesByFilter function to accept an array of components,
enabling the construction of more flexible JQL queries.
Introduced a new variable named componentQuery to represent the portion of the JQL query related to components.

Enhanced the getIssuesFromFilters function to include support for filtering by components.
Now, along with project keys and filters, the function also accepts an array of components.
This change allows for more comprehensive filtering options when retrieving issues from Jira.

Modified the router implementation to pass the array of components to the getIssuesFromFilters function.
By including components in the request, users can now specify additional criteria for filtering Jira issues,
resulting in more refined search results.

The introduced changes provide users with greater flexibility and control when retrieving Jira issues,
allowing for more precise filtering based on project keys, components, and filter criteria.
This enhancement improves the overall usability and effectiveness of the Jira integration functionality.
7 changes: 6 additions & 1 deletion plugins/jira-dashboard-backend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ export const getFilterById = async (

export const getIssuesByFilter = async (
projectKey: string,
components: string[],
query: string,
config: Config,
): Promise<Issue[]> => {
let componentQuery = '';
if (components.length) {
componentQuery = `AND component in (${components})`;
}
const response = await fetch(
`${resolveJiraBaseUrl(
config,
)}search?jql=project=${projectKey} AND ${query}`,
)}search?jql=project in (${projectKey}) ${componentQuery} AND ${query}`,
{
method: 'GET',
headers: {
Expand Down
8 changes: 6 additions & 2 deletions plugins/jira-dashboard-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ export async function createRouter(
);
}

let issues = await getIssuesFromFilters(projectKey[0], filters, config);

let components =
entity.metadata.annotations?.[componentsAnnotation]?.split(',') ?? [];
let issues = await getIssuesFromFilters(
projectKey[0],
components,
filters,
config,
);

/* Adding support for Roadie's component annotation */
components = components.concat(
Expand Down
8 changes: 7 additions & 1 deletion plugins/jira-dashboard-backend/src/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ export const getFiltersFromAnnotations = async (

export const getIssuesFromFilters = async (
projectKey: string,
components: string[],
filters: Filter[],
config: Config,
): Promise<JiraDataResponse[]> => {
return await Promise.all(
filters.map(async filter => ({
name: filter.name,
type: 'filter',
issues: await getIssuesByFilter(projectKey, filter.query, config),
issues: await getIssuesByFilter(
projectKey,
components,
filter.query,
config,
),
})),
);
};
Expand Down

0 comments on commit 7384a0d

Please sign in to comment.