summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r--app/models/time_entry.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 56801a4ca..9bf970891 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -82,11 +82,19 @@ class TimeEntry < ActiveRecord::Base
end
end
- def self.earilest_date_for_project
- TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries))
+ def self.earilest_date_for_project(project=nil)
+ finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries))
+ if project
+ finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)]
+ end
+ TimeEntry.minimum(:spent_on, :include => :project, :conditions => finder_conditions.conditions)
end
- def self.latest_date_for_project
- TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries))
+ def self.latest_date_for_project(project=nil)
+ finder_conditions = ARCondition.new(Project.allowed_to_condition(User.current, :view_time_entries))
+ if project
+ finder_conditions << ["project_id IN (?)", project.hierarchy.collect(&:id)]
+ end
+ TimeEntry.maximum(:spent_on, :include => :project, :conditions => finder_conditions.conditions)
end
end