Project

General

Profile

Calculate Spent Time in Computed Custom Field Plugin

Added by Dutch SpiritIT almost 4 years ago

I want to compute the spent time for a ticket in the Computed Custom Field Plugin. I want to do some more calculations based on that number.
Since it is not a field you can access directly (at least I could not find it), I need to calculate it.

I tried:

1. TimeEntry.sum(:hours, :conditions => {:issue_id => self.id})  
2. TimeEntry.sum(:hours, :conditions => ["issue_id =?", self.id]) 

This both results in all the spent hours in the table, no filtering is applied

TimeEntry.sum("#{TimeEntry.table_name}.hours",:joins => ["LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = ?", self.id] ).to_f

This results in 0 (Zero).

Any help?


Replies (2)

RE: Calculate Spent Time in Computed Custom Field Plugin - Added by David Casado over 3 years ago

Hi,

I think you can access to that field with "self.total_spent_hours"

Regards

    (1-2/2)