Note

We've packed up and moved from Confluence to Discourse to bring you a better, more interactive space. Out of courtesy we didn't migrate your user account so - you will have to signup again

The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
themeRDark
titleIncoming sync
// By default tempo sends over the time in seconds.
// Iterates over logged time
def totalTimeInSeconds = 0
for(int i = 0; i < replica.workLogs.size(); i++){
    totalTimeInSeconds += replica.workLogs[i].timeSpent
}

// This function makes the time readable.
def convertToReadableTime(long seconds){
    def hour = (int)Math.floor(seconds / 3600)
    seconds %= 3600
    def minutes = (int)Math.floor(seconds / 60)
    if(hour == 0){
        return "${minutes.toString()}m"
    }
    return "${hour.toString()}h:${minutes.toString()}m"
}
// Add the value to your custom field, by calling the "convertToReadableTime" function with the "totalTimeInSeconds" as parameter.
workItem.customFields."TempoCustom Worklogsfield".value = convertToReadableTime(totalTimeInSeconds)

...