Help with Jira Performance Chart
I’m trying to make a chart that shows how well we’re doing with resolving issues. I want to compare the total number of issues to the ones we’ve fixed.
Here’s what I’ve done so far:
QueryBuilder qb = new QueryBuilder();
ClauseCreator cc = qb.newClause().and().notDone();
Query allIssues;
Query openIssues;
allIssues = cc.madeAfter(daysAgo(start)).and().madeBefore(daysAgo(start - gap)).build();
openIssues = cc.madeAfter(daysAgo(start)).and().madeBefore(daysAgo(start - gap)).notDone().build();
int totalCount = issueCounter.count(currentUser, allIssues);
int resolvedCount = totalCount - issueCounter.count(currentUser, openIssues);
But when I run this, I’m getting null values. Can anyone spot what I’m doing wrong? I’m pretty new to Jira’s API, so I might be missing something obvious. Thanks for any help!
Having dealt with similar Jira API challenges, I can offer some insights. The issue might be in your query construction. Instead of using separate queries, consider using a single JQL query with appropriate filters. This approach tends to be more reliable and efficient.
Here’s a suggestion:
JqlQueryBuilder jqlBuilder = JqlQueryBuilder.newBuilder();
Query query = jqlBuilder.where().created().between(daysAgo(start), daysAgo(start - gap)).buildQuery();
SearchResults results = searchService.search(currentUser, query, PagerFilter.getUnlimitedFilter());
int totalCount = results.getTotal();
int resolvedCount = (int) results.getIssues().stream()
.filter(issue -> issue.getResolutionDate() != null)
.count();
This method should provide more accurate results. It uses a single query to fetch all issues within the date range, then filters for resolved issues using the stream API. Remember to properly handle exceptions and null checks in your actual implementation.
I’ve worked with Jira’s API quite a bit, and I think I see where you might be running into trouble. The issue is likely in how you’re constructing your queries.
Instead of using separate queries for all issues and open issues, try this approach:
- Create a single query for all issues within your date range.
- Use JQL to filter for resolved issues.
- Count the total issues and resolved issues in one go.
Here’s a rough idea of how you might modify your code:
JqlQueryBuilder jqlBuilder = JqlQueryBuilder.newBuilder();
Query query = jqlBuilder.where().createdBetween(daysAgo(start), daysAgo(start - gap)).buildQuery();
SearchResults results = searchService.search(currentUser, query, PagerFilter.getUnlimitedFilter());
int totalCount = results.getTotal();
int resolvedCount = results.getIssues().stream()
.filter(issue -> issue.getResolutionDate() != null)
.count();
This approach should give you more reliable results. Remember to handle exceptions and check for null values where appropriate. Hope this helps!