Make It Workflow — Part 7: Generating Time Reports

In our previous post, we took a look at the Time Tracking feature and showed you how to use workflows to make sure that your colleagues add work items properly (that is, avoid cheating). In this post, we describe how you can use workflows to report and analyze time tracking data.

blog_8@2x

Time Report

As usual, YouTrack offers an out-of-the-box solution — the Time Report. This report shows the total amount of time spent working on issues in one or more projects. It displays the type of work done and the original estimation. Time spent can be grouped by the type of work performed or by the users who performed the tasks.

The time report helps answer questions like:

  • How much work was recorded last week and who performed this work?
  • How was the time spent allocated between different projects?
  • Are the issues that are assigned to an employee usually overestimated or underestimated?

However, the main problem here is that you need to analyze this data manually. Every time you want to monitor this activity, you need to access the report, recalculate it, then analyze the data. If you need to do any historical analysis, you have to export the data and crunch the numbers in an external tool.

Workflows as a Reporting Tool

As always, workflows are here to help! While workflows don’t have direct access to calculated report data, they have access to the raw data in the form of issues and work items. With on-schedule rules, you can report whatever you want on a regular basis and send it to someone, whether a team lead or an employee, by email.

We start with a core module that we can use to analyze issues. This script finds all of the work items for a given assignee in a given project that were recorded within a specific time frame. As we reference this module in all of our workflow rules, we save this as a separate custom script called work-items:

Now, let’s help our team lead answer the following question: how much work did each developer log last week? We can extract the set of values from the Assignee field as the list of developers, get work items for each one of them, and calculate the difference between the time logged and required work duration (say, 40 hours for each developer).

As you may have seen in other workflows that run on a schedule, this rule uses an “anchor issue”. The anchor issue lets you pull the project that the issue belongs to into the context and iterate over other issues in the project. It also makes sure the rule runs exactly once per scheduled execution.

For an anchor issue, just create an issue with a description like “Please don’t ever delete this issue!” and set it to a resolved state. You can then reference its ID in the search property of your on-schedule rule. This makes the rule to run exactly once per each time scheduled. We’ll use this technique in the following rules.

The cool thing about this rule is that it is highly customizable. Here are just a few of the possible directions you can push this functionality:

  • Instead of using the set of values for the Assignee field, generate the list of developers based on membership in one or more groups.
  • Pull data from multiple projects and calculate the amount of time spent for each, grouping time spent by project or by developer.
  • Map the required work duration per developer instead of using a common constant.

As the second example, let’s send a reminder to the developers when the amount of work logged is less than the required work duration at the end of the week:

The same ideas for extending the previous script apply here as well, and many more. With the ability to access work items, you can calculate not only billable hours but also other numeric characteristics, like the collective velocity of your team and the relative performance of each developer.

In our next article, we show you how you can use workflows to empower your helpdesk. While we prepare the post for you, mine inspiration from our other workflow-related resources:

This entry was posted in how-to, newsletter and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *