summaryrefslogtreecommitdiffstats
path: root/app/controllers/timelog_controller.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-08-09 23:15:32 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-08-09 23:15:32 +0000
commit424b4825793ee71faa0e36e40c813bef713ca5f6 (patch)
treec14054ef52c5cda46a7b4db5d017c8e0685ff039 /app/controllers/timelog_controller.rb
parenta1b89a53eb7a6893863e787c2930fddde3385717 (diff)
downloadredmine-424b4825793ee71faa0e36e40c813bef713ca5f6.tar.gz
redmine-424b4825793ee71faa0e36e40c813bef713ca5f6.zip
Refactor TimelogController#report's joins and provide a hook to add more.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3931 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r--app/controllers/timelog_controller.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 7addff78c..e234848d0 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -55,8 +55,7 @@ class TimelogController < ApplicationController
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
sql << " FROM #{TimeEntry.table_name}"
- sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
- sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id"
+ sql << time_report_joins
sql << " WHERE"
sql << " (%s) AND" % sql_condition
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
@@ -314,4 +313,12 @@ private
call_hook(:controller_timelog_available_criterias, { :available_criterias => @available_criterias, :project => @project })
@available_criterias
end
+
+ def time_report_joins
+ sql = ''
+ sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
+ sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id"
+ call_hook(:controller_timelog_time_report_joins, {:sql => sql} )
+ sql
+ end
end