Commit d46b946e authored by Ruben Davila's avatar Ruben Davila

Add helper method #time_spent to Issuables.

This method returns the total spent time that the user has declared
through the `/spend` slash command.
parent c32e364c
...@@ -303,4 +303,8 @@ module Issuable ...@@ -303,4 +303,8 @@ module Issuable
metrics = self.metrics || create_metrics metrics = self.metrics || create_metrics
metrics.record! metrics.record!
end end
def time_spent
timelogs.sum(:time_spent)
end
end end
...@@ -255,7 +255,7 @@ module SlashCommands ...@@ -255,7 +255,7 @@ module SlashCommands
end end
command :estimate do |raw_duration| command :estimate do |raw_duration|
begin begin
@updates[:estimate] = ChronicDuration.parse(raw_duration, default_unit: 'hours') @updates[:time_estimate] = ChronicDuration.parse(raw_duration, default_unit: 'hours')
rescue ChronicDuration::DurationParseError rescue ChronicDuration::DurationParseError
# do nothing # do nothing
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment