summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-04 17:54:39 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-04 17:54:39 +0000
commit70b0bc5168aff813398334d859db1212e86a2b48 (patch)
tree185ca9abac72c1f8cf8ccbb22a84ece1a893908f /app/models
parentd8dec34ece7463ab17c78c4c4ea16497780fd91e (diff)
downloadredmine-70b0bc5168aff813398334d859db1212e86a2b48.tar.gz
redmine-70b0bc5168aff813398334d859db1212e86a2b48.zip
Adds a scope to left join the issue.
git-svn-id: http://svn.redmine.org/redmine/trunk@16481 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/time_entry.rb3
-rw-r--r--app/models/time_entry_query.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 241ff2ffc..2376f36b0 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -54,6 +54,9 @@ class TimeEntry < ActiveRecord::Base
joins(:project).
where(TimeEntry.visible_condition(args.shift || User.current, *args))
}
+ scope :left_join_issue, lambda {
+ joins("LEFT OUTER JOIN #{Issue.table_name} ON #{Issue.table_name}.id = #{TimeEntry.table_name}.issue_id")
+ }
scope :on_issue, lambda {|issue|
joins(:issue).
where("#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}")
diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb
index eab1113e2..063074496 100644
--- a/app/models/time_entry_query.rb
+++ b/app/models/time_entry_query.rb
@@ -115,7 +115,7 @@ class TimeEntryQuery < Query
def base_scope
TimeEntry.visible.
joins(:project, :user).
- joins("LEFT OUTER JOIN issues ON issues.id = time_entries.issue_id").
+ left_join_issue.
where(statement)
end