annikoff/redmine_plugin_computed_custom_field

Sum of dedicated time of a tracker type in the project

mavag opened this issue · 5 comments

mavag commented

Hello, on ticket # 64 I have seen how to add all the dedicated hours of project tickets, but this is for all types of tickets:

time_entries.sum (: hours) .round (2)

Is there a way to do it with only one type of ticket?

Many thanks for the help

Hi. What is a type of ticket?

mavag commented

Tracker

time_entries.includes(:issue).where(issues: { tracker_id: YOUR_TRACKER_ID }).sum(:hours).round(2)

mavag commented

Ouuuuuyeaaaa!! Thanks!!!

mavag commented

Extensive information for the result to be in time format:

hours = time_entries.includes(:issue).where(issues:{YOUR_TRACKER_ID}).sum(:hours).round(2)
hours_part = hours.truncate
minutes = ((hours - hours_part) * 60).round
result = hours_part.to_s + ":" + minutes.to_s