Cycles on task in Easy BI

Hi Easy BI team,

As i know how we can see the report of average days.

I need to know the count of cycles.

Is there a quick way to get this value?

The objective is to create a report which shows us how much time do we take in giving feedback for a certain task after the first time it goes for client review. So basically we need to calculate the time between the second time its in production till its back in ready for client review.

please suggest me resolution

Thanks &Regards,
Aparna

Hi @Appam,

You might create a new JavaScript calculated custom field that finds the number of work cycles based on work statuses and another one to check if the issue already went for customer review and then find the time spent in re-work statuses.

Please read more about JavaScript calculated customfields here - JavaScript calculated custom fields.

The script for “Entered production cycles” might be as follows.

[jira.customfield_numcycles]
name="entered production cycles"
data_type="integer"
multiple_dimensions=["Time"]
measure=true
javascript_code='''

var isWorked = false;
var forCount = false;
var numcycles = 0;
var result = new Array();

var workStatuses = ["In Progress", "Processing", "Investigating"];

if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
    var histories = issue.changelog.histories;
    for (var i = 0; i < histories.length; i++) {
        var history = histories[i];
        if (history.items && history.items.length > 0) {
            for (var n = 0; n < history.items.length; n++) {
                var item = history.items[n];
                if (item.field == "status") {
                    if (workStatuses.indexOf(item.toString) > -1 && !isWorked) {
                        isWorked = true;
                        forCount = true;
                    } else if (workStatuses.indexOf(item.toString) == -1 && isWorked) {
                        isWorked = false;
                    }
                }
            }
            if (isWorked && forCount ) {
              result.push(history.created.substr(0,10)+ ",1");
              forCount = false;}
            }
        }
   if(result){
    issue.fields.customfield_numcycles = result.join("\n");
   } 
}
'''

The script for “Rework days by date” might be like this.

[jira.customfield_rewtime]
name="Rework days by date"
data_type="decimal"
measure=true
multiple_dimensions=["Time"]
javascript_code='''

var inReview = false;
var isWorked = false;
var forCount = false;
var duration = 0;
var currStartDate = null;
var oldStartDate = null;
var result = new Array();

var workStatuses = ["In Progress", "Processing", "Investigating"];
var reviewStatuses = ["Ready for review", "Client review"];

if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
    var histories = issue.changelog.histories;
    for (var i = 0; i < histories.length; i++) {
        var history = histories[i];
        if (history.items && history.items.length > 0) {
            for (var n = 0; n < history.items.length; n++) {
                var item = history.items[n];
                if (item.field == "status") {
                    if (reviewStatuses.indexOf(item.toString) > -1) {
                     inReview = true;
                    }
                    if (workStatuses.indexOf(item.toString) > -1 && !isWorked && inReview) {
                        isWorked = true;
                        currStartDate = history.created;
                        oldStartDate = currStartDate;
                    } else if (workStatuses.indexOf(item.toString) == -1 && isWorked && inReview) {
                        isWorked = false;
                        forCount = true;
                    }
                }
                if (!isWorked && forCount) {
                    oldStartDate = currStartDate;
                    currStartDate = history.created;
                    duration  =  ((Date.parse(currStartDate) - Date.parse(oldStartDate)) / 1000 / 60 / 60);
                    result.push( currStartDate.substr(0,10)+ ","+ duration);
                    forCount = false;                
                }
            }
        }
    }
}
if(result){
    issue.fields.customfield_rewtime = result.join("\n");
   }
'''

Please replace current statuses in workStatuses and reviewStatuses with the relevant statuses on your Jira instance.

After a successful data import, you might then find the number of work cycles with the measure “Entered production cycles”.
The measure “Rework days by date” would return the time spent in rework assigned to the Time dimension to the date of exiting re-work.

Please note that these measures are only mapped to Time and Issue dimensions. It means that if you have any other dimensions in the report, you might create a calculated measure within the Measures dimension to disable these extra dimensions for the specific measure using .DefaultMember reference.

Please see below an example of an expression that allows ignoring the Priority dimension for the measure “Rework days by date”.

([Measures].[Rework days by date],
​ [Priority].DefaultMember)

​​
Regards,
​Oskars / support@eazyBI.com