I am attempting to generate the following chart in xCharts:
x-axis = time (grouped by week or month)
y-axis = count of issues
The issue is that I only want to count the issue if a specific label was added during the time frame specified in the x-axis. I believe this information can be taken from the historical change log in the jira issue.
I have gotten as far as the below code (excluding imports):
def metaCountGroup = chartBuilder.newDataCollector();
DateFormat dateformat = DateUtils.SimpleDateFormat;
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class);
Query query = null;
try
{
query = jqlQueryParser.parseQuery(JQL);
} catch (JqlParseException e)
{
throw new IllegalArgumentException("Bad JQL: " + query);
}
Period selectedPeriod = Period.MONTH;
ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager();
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager);
Date now = new Date();
Field documentField;
Map<String, String> changeHistoryItem = null;
try
{
documentField = DocumentIssueImpl.class.getDeclaredField("document");
documentField.setAccessible(true);
// iterate over the issues
for (Issue issue : chartBuilder.getFilterUtils().performSearch(query, user) )
{
// iterate over the issue change history
for (ChangeHistoryItem item : changeHistoryManager.getAllChangeItems(issue) )
{
changeHistoryItem = item.getTos();
if (changeHistoryItem.containsValue("labelThatIAmInterestedIn")) {
Calendar cwCreated = dateUtils.getStartOfPeriod(item.getCreated(), selectedPeriod);
String cw = dateFormat.format(cwCreated.getTime());
metaCountGroup.addValue(BigDecimal.ONE, issue.getIssueType().getName(), cw);
}
}
}
} catch (Exception e)
{
throw new RuntimeException(e);
}
ChartData chartData = chartBuilder.newChartData("Issues");
chartData.setxFormat("%Y.%m.%d);
chartData.setType("line");
chartBuilder.getChartUtil().transformResult(metaCountGroup, chartData, false);
return chartData;
When I change "labelThatIAmInterestedIn" to "Analysed" for example, the chart successfully shows the number of issues which were set to status "Analysed" on the relevant date.
However, when I change this to a label the chart does not show any matches.
I believe this could be an issue either with the changeHistoryManager.getAllChangeItems(issue) not getting any information for the labels (though I have no idea why that would be the case) or if this is not the case and the changeHistoryItem is a map<Labels, "Label Label Label etc"> then changeHistoryItem.containsValues is always giving false as "Label Label Label etc" is never exactly equal to the label I am searching for?
Alternatively, it could be something completely different so any help would be much appreciated, thanks in advance.
Does anyone know if this is even possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.