Provide a method of recording how much time was spent on tasks.

This can be combined with #2402941: Task assignment to manage staff hours.

Comments

m.stenta’s picture

Here is a potential module we can leverage for this: https://www.drupal.org/project/time_tracker

m.stenta’s picture

Nevermind my last comment - that modules is only for nodes, and only for Drupal 7.

To start we can just add a decimal field for tracking how much time was spent on each log. Then we can add enhancements on top of that later...

kadaan’s picture

Should this change actually be made in mstenta/log?

kadaan’s picture

Also, I think it would be nice to have an action which would let you start the task. It would set a hidden field with the start datetime. Then, when you complete the task with the "done" operation, it automatically populates the time spent field. Additionally, when you create or edit a task, if the done field is set to true, the time spent field will be editable. If the hidden start time field is set, time spent will be prepopulated. What do you think?

BruceDawson’s picture

Kadaan: I think that would be good. But we would need a way to "edit" the time spent on a task. I know I spent time on a task, then someone asks me a question unrelated to the task, and it takes a while to reply, or there's some other interruption.

Another killer of time tracking for me is "unscheduled blocks"... typically a managerial thing - when something else takes a "managerial priority" over the project.

kadaan’s picture

@BruceDawson: I was thinking that the "Time Spent" field would be defaulted to "now - StartTime", but it would still be editable.

I'm not sure how to handle the "unscheduled blocks", but maybe we can tackle that later.

m.stenta’s picture

I spent some time talking with @kadaan in IRC about this. Here's the current thinking...

First, this should not be done directly in the Log module - because time tracking is not a general requirement of all logs (the Log module is not only used by farmOS). So then we have two options:

1) We add a time_spent field to each of the log types in farmOS, like we do for most of the other farmOS-specific log fields.

or

2) We create a new module that extends the Log module with an additional database table for time tracking purposes. It could also have configuration for allowing you to select which log types should have time tracking available on them.

#1 might be a good short-term solution, but it might not be a whole lot of work to just get started on #2 instead. I think that is the better long term solution.

Another idea we discussed is that instead of just tracking a single number (time spent) on each log, we instead create a sort of "timesheet" for each log. Users could punch in/out and record multiple time periods spent on a single task - across different days even. And different users could log time as well, so it could later be broken down to determine who spent time where very accurately. Combined with a per-user $/hr value, we could get very fine-grained calculations of how much a given task cost, based on who worked on it and for how long. And of course, we could also calculate total time spent by everyone on it.

@BruceDawson - I think that would cover the considerations you brought up, yes?

What do you think? If that sounds like a good plan we could start specing up what that module would need to look like.

BruceDawson’s picture

m.stenta: I think the idea of "punching in and out" of a task is the best way to go.

m.stenta’s picture

The punch in/out buttons could be added to the log view page (much like we plan to do in: #2513056: Display action buttons on log/asset view page) - and conditionally display them based on whether or not your are punched in or not.

We could also provide a Views field handler so that the button could be included in the log lists as well. For example, in the todo list and late tasks lists in the dashboard, each line could have a button allowing you to punch in/out on it. This would send an AJAX request in the background to the server, and update the button (maybe display a running timer), without requiring a page reload.

m.stenta’s picture

I started an initial module that @kadaan will help with. It is on Github now, but I will create an official drupal.org repository eventually: https://github.com/mstenta/log_timesheet

First commit just creates the module files. Second commit sets up a new database table:

log_timesheet

* id - links to a specific log entity
* uid - the user entering the time period
* start - the start time
* end - the end time

I think that will cover all the basic data that we'll need, right? The idea being that we'll create UI for users to punch in/punch out on specific logs. When they punch in it will create a new record in the database, linked to the log, linked to their user id, and it will fill in the "start" timestamp. When they punch out, it will fill in the "end" timestamp.

Since the timestamps will be unix timestamps, they will be a measure of seconds, so we can easily calculate duration by subtracting the start from the end, and converting to minutes/hours/etc. We can create a custom Views Field Handler to do this for us in the query itself, so that it can be included in Views-based lists.

m.stenta’s picture

Brainstorming some of the next things we'll need here:

* Add a very simple punch-in/punch-out button to the entity view page for logs (/log/*)
* This could be done with the Drupal form API, using the #ajax parameter to avoid a page reload (but still work gracefully without JS)
* Views integration for the {log_timesheet} table via hook_views_data()
* Add a new page for viewing all timesheet entries for each log at /log/*/timesheet
* Also add the punch in/out button on this page.
* Ability to manually add/edit/delete entries
* Views Field Handler for calculating total time spent
* Automatically simplify long stretches of time. For example: 793474 seconds is simplified to "1 week, 2 days, 4 hours, 24 minutes, 34 second" (extreme example)

Future features could include:

* UI for viewing all the timesheet entries for a given user (independent of logs) so you could see how much someone worked in a given period of time, and what they worked on

m.stenta’s picture

We should also include a text field alongside each timesheet entry called "Summary" that can be used for notes about what was done. In tasks that take a long time, or involve many people, it will be necessary to take note of what was done during each session.

m.stenta’s picture

We will also need to have a simple "total time" or "duration" column in the database, to offer the ability to simply enter a total amount of time spent on a task, rather than using a start/end time. Not everyone will be punching in/out all the time. Or times may be entered after the fact and just estimated - in which case an exact start and end time is not known.

m.stenta’s picture

Title: Time tacking » [META] Time tacking
Version: 7.x-1.x-dev » 2.x-dev

Following on some new thinking that is happening in the farmOS 2.x development branch, I've created a new issue which may be the first step towards time tracking in farmOS: #3196844: Time quantities

This depends on #3196825: Quantity types, which in turn depends on #3196819: Quantity entities.

Note that #3196844: Time quantities ONLY focuses on the underlying data storage mechanisms for time tracking. It does NOT worry at all about UI. That should be done in a follow-up issue, or as part of a new Field Module in Field Kit.

Renaming this issue to indicate that it's a meta discussion now, and perhaps we can use it to spin off and link to other issues. Also changing it to the 2.x branch because that's where all new feature development is focused.

m.stenta’s picture

Status: Active » Closed (outdated)

Closing old discussion issues - let's use the forum instead.