Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to calculate (cumulative) the flagged time of an issue?

Rafael Pessoa October 23, 2024

Hi there community!

 

I´m trying to calculate the cumulative time that an issue has been flagged, but I´m not convinced with the values that I´m receiving. 

Long story short, I´ve created a field called Idle Time to receive the time flagged in seconds and I'm trying to print the total value of this field as a comment. I´m using the issue.dueDate field to save the moment that the issue was flagged with {{now}}

This is the data that I´m using to populate the Idle Time:
{{#=}}{{issue.Idle Time}} + {{now.diff(issue.Due Date).Seconds.abs}}{{/}}

 

This is the data that I´m using to comment the issue after removing the flag:
{{issue.Due Date.diff(now.plusSeconds(issue.customfield_10198)).prettyPrint}}

This is the automation that I made:

AutomationFlagged.PNG

The problem is that the value that I´m receiving in Idle Time Field seems to be wrong according to the time that the issue was flagged. For example, if I block the issue for 10 seconds, it display a crazy value like 39000 (milliseconds maybe?)

What am I missing here?

 

2 answers

2 accepted

3 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 23, 2024

Hi @Rafael Pessoa -- Welcome to the Atlassian Community!

What you show will not work with the Due Date field: as Trudy describes that field is a date field and does not have the resolution of date / time.

With an automation rule, there are two ways I can think of to gather the cumulative time an issue was in a flagged condition, and both have limitations leading to possible measurement errors.

  • Use two custom fields, one for the starting date / time an issue was flagged and another for the cumulative result
    • The rule will detect when an issue enters flagging to start the clock and detect when it leaves flagging to accumulate the results and clear the clock
    • This can be a brittle approach as it is quite easy to toggle the flag, and this could cause race-track errors in the rule...
    • And any rule engine outage from Atlassian will prevent measurement
  • Use the data from the comments directly
    • There are some "magic" comment values added when the flag field is toggled on or off: "(flag) Flag added" and "(flagoff) Flag removed", respectively
    • Using dynamic list searching methods, the comments can be filtered for the above values, and the time difference for the last two (i.e., off and on), be used to increment the timer.
    • This is a more complicated approach, and so is prone to implementation errors

 

Kind regards,
Bill

Rafael Pessoa October 24, 2024

Hi Bill, thank you for your answer! 

I never thought to use comments as inputs but let´s give it a try.

I´ll create another field and test the solution with it. I´ll try to implement the second solution and post here so the community can also benefit from it.

 

Like Bill Sheboy likes this
2 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 23, 2024

Hello @Rafael Pessoa 

Welcome to the Atlassian community.

The built in Due Date field is a Date field, not a Date/Time field. When you set it to now() you get only the date. When you then use that in a date difference calculation it uses 00:00 as the Time.

You need to use a custom date/time type of field to record the moment the issue is flagged.

Rafael Pessoa October 24, 2024

Thank you @Trudy Claspill this explains a lot! I´ll change and post the results here so the community can also benefit from it.

Like Trudy Claspill likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events