Calculating the number of comments - by specific USER

Hi @chrischarles2002,

In the mentioned community post Calculating the number of comments , is an example of how to import comment count using JavaScript calculated custom fields.

To count comments by each author, you may modify JavaScript code. To do this, declare that each issue might have a set (array) of user names who have commented on it and comment count accordingly. To represent names of comment authors in eazyBI, you may use some existing dimension which contains user names, like, Assignee dimension.

Code for advanceds settings with JavaScript calcaulted custom field might look like this:

#Comments by user - Assignee
[jira.customfield_comments_byuser]
name = "Comments by user"
data_type = "integer"
measure = true
multiple_dimensions = ["Time","Assignee"]
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];
      commenta.push(comment.created.toString().substr(0,10) + "," + comment.author.name + ",1");
  }
  issue.fields.customfield_comments_byuser = commenta.join("\n");
}
'''

In a report, use Assignee dimension to represent comment count by authors.

Best,
Zane / support@eazyBI.com

1 Like