summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 140071872..dd512017f 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -28,7 +28,7 @@ class Issue < ActiveRecord::Base
has_many :journals, :as => :journalized, :dependent => :destroy
has_many :attachments, :as => :container, :dependent => :destroy
-
+ has_many :time_entries
has_many :custom_values, :dependent => :delete_all, :as => :customized
has_many :custom_fields, :through => :custom_values
@@ -91,6 +91,10 @@ class Issue < ActiveRecord::Base
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
@current_journal
end
+
+ def spent_hours
+ @spent_hours ||= time_entries.sum(:hours) || 0
+ end
private
# Creates an history for the issue