YouTrack Standalone 2017.2 Help

Work Timer

This workflow lets your development team track the time spent working on an issue and log work items automatically.

File Name

jetbrains-youtrack-workTimer

Auto-attached

no

Rules

Start timer (stateless)
Stop timer (stateless)

To enable this workflow:

  1. Enable and configure time tracking for your project.

  2. Add a date-type field with the name Timer time to your project.

  3. Attach the Work Timer workflow to your project.

For this workflow to function as written, your project must use a State field that includes the values In Progress and Fixed. If you use different fields and values to track the status of issues in your project, modify the workflow accordingly.

Use Case

When a developer changes the state of an issue state to In Progress, the workflow enters the current time in the Timer time field. When the developer changes the state to Fixed, a work item with the time spent between the Timer time and the current is added to issue on behalf of the user who fixed the issue.

Rules

This workflow includes two rules.

Start timer

When the state of an issue is changed to In Progress, this rule sets the value of the Timer time to the current time.

rule Start timer when State.becomes({In Progress}) { Timer time = now; message(l10n ( The timer is started. )); }

Stop timer

When the state of an issue is changed to Fixed, this rule calculates the time spent working on the issue and adds a work item to the issue. The work item includes a message that is defined by this rule and the calculated time spent.

rule Stop timer when State.becomes({Fixed}) { if (State.oldValue == {In Progress}) { 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. ) + "\n"); } }
Last modified: 7 March 2019