Module: RateTimeEntryPatch::ClassMethods

Defined in:
lib/rate_time_entry_patch.rb

Instance Method Summary collapse

Instance Method Details

#update_cost_cache(user, project = nil) ⇒ Object

Updated the cached cost of all TimeEntries for user and project



20
21
22
23
24
25
26
27
28
# File 'lib/rate_time_entry_patch.rb', line 20

def update_cost_cache(user, project=nil)
  c = ARCondition.new
  c << ["#{TimeEntry.table_name}.user_id = ?", user]
  c << ["#{TimeEntry.table_name}.project_id = ?", project] if project
  
  TimeEntry.all(:conditions => c.conditions).each do |time_entry|
    time_entry.save_cached_cost
  end
end