YouTrack Standalone 2017.1 Help

Standalone Work Timer

This workflow enables a timer that tracks the amount of time spent working on an issue.

File Namejetbrains-youtrack-standaloneWorkTimer
Auto-attachedno
RulesStart timer: switch to 'Start' (stateless)
Stop timer: switch to 'Stop' (stateless)

To enable this workflow:

  1. Enable and configure time tracking for your project.
  2. Add an enumerated field with the name Timer to your project. Add the values Start and Stop to the field.
  3. Add a date-type field with the name Timer time to your project.
  4. Attach the Work Timer workflow to your project.

Use Case

This workflow enables a timer that you can use to track the amount of time you spend working on an issue. When you stop the timer, the elapsed time is automatically added to the issue as a work item.

Rules

This workflow includes two rules.

Start timer: switch to 'Start'

The first rule starts the timer.

rule Start timer: switch to 'Start' when Timer.becomes({Start}) { Timer time = now; message(l10n ( The timer is started. )); }

The second rule stops the timer. The elapsed time is added to the issue as a work item.

Stop timer: switch to 'Stop'

rule Stop timer: switch to 'Stop' when Timer.becomes({Stop}) { if (Timer.oldValue == {Start}) { 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(l10n ( Work time: {days} day(s) {hours} hour(s) {minutes} minute(s). )); } else if (hours!=0) { message(l10n ( Work time: {hours} hour(s) {minutes} minute(s). )); } else { message(l10n ( Work time: {minutes} minute(s). )); } issue.applyCommand(l10n ( add work Today {days + " "} d {hours + " "} h {minutes + " "} m ) + " " + l10n ( The work item automatically added by the timer. )); } else { message(l10n ( Looks like the timer hasn't been started. )); } }
Last modified: 18 April 2017