Time tracking of submitting issues

We try to measure also time spent on submitting issues, because sometimes analytics spend a lot of time creating issues. So we created WF like this:
rule New issue writing
 when isReported() == false && Timer time == null {
  Timer time = now;
 }
prettyPrint();
And another rule:
rule New issue submitting
 
when becomesReported() && Timer time!=null {
 var duration = now - Timer time;
 var seconds = (duration.millis-duration.millis%1000)/1000;
 var minutes = (seconds-seconds%60)/60;
 var hours = (minutes-minutes%60)/60;
 var days = (hours-hours%24)/24;
 
 minutes = minutes%60;
 hours = hours%24;
 if(days!=0){
  message("Issue creating time"+days+"day(s)"+hours+"hour(s)"+minutes+"minute(s).");
 } else if(hours!=0){
  message("Issue creating time"+hours+"hour(s)"+minutes+"minute(s).");
 } else if(minutes>0){
  message("Issue creating time"+minutes+"minute(s).");
 }
 if(seconds >= 60) {
  issue.applyCommand("add work Documentation Today"+days+"d"+hours+"h"+minutes+"m Work item added by trigger");
 }
}
prettyPrint();

And now, what is going wrong? When I start to write new issue, Timer time is started. It's OK. When a submit it, second rule is triggered and total time is counted. OK. But no Time tracking line is added to this issue. And what is much worse, when I start to create another issue, total creating time from first issue is set as "Spent time" in newly created issue. No Time tracking lines are there, but Spent time is set. And there is no way how to reset it.

What is wrong? Where is problem? It is a feature of YT that is unable to time track issues until submitted?
Thx.
5 comments
Comment actions Permalink
Are you sure that the condition seconds >= 60 is passed? You can check it by applying another command.

And what is much worse, when I start to create another issue, total creating time from first issue is set as "Spent time" in newly created issue.

Probably you create a subtask? If so Spent Time is inherited from the parent task to the subtask.
0
Comment actions Permalink
Yes, I am sure that this condition is passed. I tested it by addCommand command in WF of course. I just didn't post this "debug" version.

And no, it is not any subtask. Try to reproduce this behaviour. Both (first issue, second issue) are simple tasks, without any subtask, without any child issues. Every minute "add work" is couted into "Spent time" of second issue.

It is really strange behaviour. I guess it must be some bug in YT.
0
Comment actions Permalink
It seems you've missed the space in the expression after "Today": issue.applyCommand("add work Documentation Today "+days+"d"+hours+"h"+minutes+"m Work item added by trigger");
When a submit it, second rule is triggered and total time is counted. OK.

Please clarify - do you mean this workflow works itself but applyCommand? I don't see any field assignment to set Spent time. If the applyCommand isn't applied who else can set Spent Time?
0
Comment actions Permalink
No, missing space is just transcription mistake.
Let's go to simulate it. Try to create this VERY SIMPLE workflow with two Stateless rules:
rule New issue writing 

when isReported() == false && Timer time == null { 
  Timer time = now; 
}

rule New issue submitting 
 
when becomesReported() && Timer time != null { 
  var myCmd = ""; 
  myCmd = "add work Today 0d0h7m Timer test"; 
  addComment(myCmd); 
  applyCommand(myCmd, loggedInUser); 
}
prettyPrint();
Then assing it to any project.
When You start to write a new issue, Timer time is written down. It works well.
When You submit new issue, second rule is started. It is still OK.
I made it as simple as possible. No counting of time, just add 7 minutes as work.
When triggered, it add new comment "add work Today 0d0h7m Timer test".
But it doesn't add any Time tracking record. Try it, please, You will see.

Then try to create another new issue.
When form with new issue appears, You can see,that there is Spent time 7m.
Absolutelly new issue and 7 minutes Spent time? Why?
There are no records in Time tracing tab, no way how to delete this 7 minutes.
No, they are not any subtask, nothing like that.

Please just test it and You will see what I am talking about.
0
Comment actions Permalink
Well, thank you for detailed feedback, I've created JT-26735.
0

Please sign in to leave a comment.