This feature proposal is extracted from this bigger ticket: gitlab-ce#33211. You may also want to check this original ticket if some context is lacking.
We are in the process of migrating our Trac setup to GitLab EES. We are heavily using time tracking internally, and our main use case is that when anything that has a time field happen in Trac, a webhook is triggered in our (custom) CRM to generate (1) a feed of events showing the comment and time tracked , and (2) an aggregate of the time tracked to calculate our hours worked and overtime as soon as an event happen.
Right now, the webhook triggered when a note is added, only contained the aggregated time on the whole ticket like so:
Our proposal would be to add at least a machine-readable field containing time that got tracked. A human readable field could also be added for convenience, but the machine readable one is actually the most important of the two to digest the webhook easily:
The advantage of a setup like this is that one could easily plug any time tracking system that can react on webhook or API trigger. The fact that the field is machine-readable also help simplify the parsing of such information.
Mark Fletcherchanged title from Proposal: add the changed time in the note webhook at least in a machine readable format to Add the changed time in the note webhook at least in a machine readable format
changed title from Proposal: add the changed time in the note webhook at least in a machine readable format to Add the changed time in the note webhook at least in a machine readable format
Any news about the prioritisation of this proposal? From my interaction via GitLab's Support it seems you were waiting for your next internal meeting to see about this.
Also, if there is anything we can do to help move this forward don't hesitate to ping us about it :)
Yes. Since the webhook contains what changed when an event happen (I use the event here for any user input changing the state of the issue tracker), it would make sense to provide not only the new state, but the changed delta.
This will also simplify using tools in a more plug-n-play fashion. One can just hook-up a tool to the hook, and start gathering interesting data without having to know or import the state of the system beforehand.
Following the comments on gitlab-ce#40122 about future change of GitLab 10.2, I am currently downloading the last RC to check if that resolve our business case.
@harry-hov yes correct, that is my understanding as well based on above comments:
So this proposal is to deliver the difference between the old and new values for consumers that don't store the original time spent?
Yes. Since the webhook contains what changed when an event happen (I use the event here for any user input changing the state of the issue tracker), it would make sense to provide not only the new state, but the changed delta.
I have few more queries those are maybe worth discussing:
Unlike total_time_spent, time_change can be negative. How do we want to represent -ve time_change in human understanding format? maybe like "-1h30m"? I'm not sure.
What if total_time_spend becomes 0?.
Here comes the 2 possible cases:
Case 1:
/spend 1h/spend -1h
In that case current webhook response looks something like this:
Thanks @acroitor for your response. I tried and I guess /assign @harry-hov isn't working for me. I'm not sure if I have the right permission to do this?
ok, this seems to be expected behaviour based on the documentation
You can remove time by entering a negative amount: for example, /spend -3d removes three days from the total time spent. You can’t go below 0 minutes of time spent, so GitLab automatically resets the time spent if you remove a larger amount of time compared to the time that was entered already.
@harry-hov I think it's fine to press on with returning the delta from the actual change in total time spent. So if that is currently 0, time_change should be 0 also. Even if it's unexpected behaviour.
@johnhope I assumed it should just set the total_time_spent to 0 initially as well, maybe we should change that behaviour as it does not really make sense to me either, but I am not sure about the number of affected users with this behaviour change
@johnhope it is documented so I guess it is intended,
Even if it is intended. I think this
message is bit misleading. It should be something like "Hey, the value you want to subtract is bigger than the actual value of total_time_spent". According to me, it should not be a SUCCESSFUL message at least.
@acroitor@harry-hov I would not expect you to be able to subtract more time than exists.
If I spend 3h and then -4h, I am technically only subtracting 3h. Subtracting 4h from 0 is still 0.
The rule would basically be -- subtract the difference between time_spent. If time_spent will equal 0, then only subtract the actual time removed. This way it isn't confusing in the success messages as you can't ever subtract more time than time spent.
If I spend 3h and then -4h, I am technically only subtracting 3h. Subtracting 4h from 0 is still 0.
@gweaver If I spend 3h and then -4h. Value of total_time_spent remains unchanged i.e 3h. So technically we are subtracting nothing if time_spent exceeds total_time_spend?
@gweaver I agree with the scenarios above. The only thing to mention(and I think you are aware of it) is that the last scenario where you subtract more than time spent, currently does not work as presented by you, which raises the question of how many customers are relying on that weird behaviour and can potentially be affected by the change in behaviour?
I still lean towards changing the behaviour, just because it makes sense, and I am not sure we have the numbers on customer usage on time spent feature, do we ?
@gweaver@acroitor Looks like we're all agreed it should work by setting the value to 0 instead of ignoring the negative time spent. Could we split the work to correct this behavior out from this issue to give @harry-hov an easier time?
I don't see too much duplication of work but fixing the behavior will require a docs update and we should check the impact as @acroitor says. @harry-hov could include the time_change and human_time_change attributes just as it works now, then in the next issue we fix the bug so the right amount of time is subtracted.
Works for me @johnhope. @acroitor in terms of changing the existing behavior, I'm not concerned about disrupting anyone honestly. It's a logical correction. In terms of usage, there are about 11.6k folks that track time and about 4.3k that set time estimates.