Hello,
In a Jira project I want to find out how many people are collaborating in solving the tickets.
Ideally I want a report in which I see all the comment authors and how many comments they have done in the project/tickets.
The problem is all the questions asked here similar to this one use a scripted field that matches the commenters with the assignees of the project (or reporters).
My users might have never been assignees or reporters of any issue. I need a dimension that is “Comment authors” or something similar to do the counting.
I tried importing all employees of the company as a new dimension but it needs to be associated to other user dimension and I end up restricted by assignee again.
How can I make a dimension of Comment Authors (or employees) so I can count how many comments each of them have done?
Best Regards
Hi, @Lara_LG
Welcom,
Please consider creating an empty dimension and using it with another JavaScript dimension containing all the comment authors and the Time dimension.
Please go to the site Settings → Advanced Settings and add the code:
## empty dimension
[jira.customfield_commauth]
name = "Comment author"
data_type="string"
dimension=true
separate_table=true
## Coment Author with Time dimension
[jira.customfield_comments_byuser]
name = "Comments by user"
data_type = "integer"
measure = true
multiple_dimensions = ["Time","Comment author"]
javascript_code = '''
var commenta = new Array();
var allcomments = issue.fields.comment;
if (allcomments && allcomments.comments ) {
var comments = issue.fields.comment.comments;
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
if(comment.author)
{
commenta.push(comment.created.toString().substr(0,10) + "," + comment.author.displayName + ",1");
}
else
commenta.push(comment.created.toString().substr(0,10) + "," + "(no author)" + ",1");
}
issue.fields.customfield_comments_byuser = commenta.join("\n");
}
'''
Save the settings and go to Jira Import options.
Import both fields “Comment author” and “Comments by user”. See the screenshot:
The report should look something like this:
Kindly,
Ilze
@ilze.mezite thanks for your reply. Is it possible to create simple calculated field to get only user names who commented w.r.t each issue?
Hi Ilze!
Thank you for the piece of code and approach, this was really helpful in one of our requests!
However, I had to make some changes to the code myself to fit the requirements. We needed to only track comments from licensed Jira users and only public comments (helpful for JSM implementations in which we want to track how many comments agents created in a timeframe).
Here’s my version!
## empty dimension
[jira.customfield_commauth]
name = "Comment author"
data_type="string"
dimension=true
separate_table=true
## Comment Author with Time dimension
[jira.customfield_comments_byuser]
name = "Comments by user"
data_type = "integer"
measure = true
multiple_dimensions = ["Time","Comment author"]
javascript_code = '''
var commenta = new Array();
var allcomments = issue.fields.comment;
if (allcomments && allcomments.comments ) {
var comments = issue.fields.comment.comments;
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
if(comment.jsdPublic &&(comment.author && comment.author.accountType === "atlassian"))
{
commenta.push(comment.created.toString().substr(0,10) + "," + comment.author.displayName + ",1");
}
}
issue.fields.customfield_comments_byuser = commenta.join("\n");
}
'''
The changes are in the if statement which I replaced with:
if(comment.jsdPublic &&(comment.author && comment.author.accountType === "atlassian"))
Kudos to Martins from eazyBI support as well, I got stuck in some areas and his advice and support were so helpful!