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
This commit is contained in:
parent
a1b89a53eb
commit
424b482579
|
@ -55,8 +55,7 @@ class TimelogController < ApplicationController
|
||||||
|
|
||||||
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
|
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
|
||||||
sql << " FROM #{TimeEntry.table_name}"
|
sql << " FROM #{TimeEntry.table_name}"
|
||||||
sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
|
sql << time_report_joins
|
||||||
sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id"
|
|
||||||
sql << " WHERE"
|
sql << " WHERE"
|
||||||
sql << " (%s) AND" % sql_condition
|
sql << " (%s) AND" % sql_condition
|
||||||
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
|
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 })
|
call_hook(:controller_timelog_available_criterias, { :available_criterias => @available_criterias, :project => @project })
|
||||||
@available_criterias
|
@available_criterias
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue