Gantt: Avoid unnecessary queries before rendering.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4476 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
318bd10c7f
commit
4715a37937
|
@ -59,11 +59,13 @@ end
|
||||||
|
|
||||||
# Width of the entire chart
|
# Width of the entire chart
|
||||||
g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
|
g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
|
||||||
# Collect the number of issues on Versions
|
|
||||||
|
@gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width)
|
||||||
|
|
||||||
g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max
|
g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max
|
||||||
t_height = g_height + headers_height
|
t_height = g_height + headers_height
|
||||||
|
|
||||||
@gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width)
|
|
||||||
%>
|
%>
|
||||||
<table width="100%" style="border:0; border-collapse: collapse;">
|
<table width="100%" style="border:0; border-collapse: collapse;">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -70,6 +70,7 @@ module Redmine
|
||||||
|
|
||||||
@subjects = ''
|
@subjects = ''
|
||||||
@lines = ''
|
@lines = ''
|
||||||
|
@number_of_rows = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def common_params
|
def common_params
|
||||||
|
@ -91,6 +92,8 @@ module Redmine
|
||||||
### Extracted from the HTML view/helpers
|
### Extracted from the HTML view/helpers
|
||||||
# Returns the number of rows that will be rendered on the Gantt chart
|
# Returns the number of rows that will be rendered on the Gantt chart
|
||||||
def number_of_rows
|
def number_of_rows
|
||||||
|
return @number_of_rows if @number_of_rows
|
||||||
|
|
||||||
if @project
|
if @project
|
||||||
return number_of_rows_on_project(@project)
|
return number_of_rows_on_project(@project)
|
||||||
else
|
else
|
||||||
|
@ -146,6 +149,7 @@ module Redmine
|
||||||
|
|
||||||
@subjects = '' unless options[:only] == :lines
|
@subjects = '' unless options[:only] == :lines
|
||||||
@lines = '' unless options[:only] == :subjects
|
@lines = '' unless options[:only] == :subjects
|
||||||
|
@number_of_rows = 0
|
||||||
|
|
||||||
if @project
|
if @project
|
||||||
render_project(@project, options)
|
render_project(@project, options)
|
||||||
|
@ -171,6 +175,7 @@ module Redmine
|
||||||
|
|
||||||
options[:top] += options[:top_increment]
|
options[:top] += options[:top_increment]
|
||||||
options[:indent] += options[:indent_increment]
|
options[:indent] += options[:indent_increment]
|
||||||
|
@number_of_rows += 1
|
||||||
|
|
||||||
# Second, Issues without a version
|
# Second, Issues without a version
|
||||||
issues = project.issues.for_gantt.without_version.with_query(@query)
|
issues = project.issues.for_gantt.without_version.with_query(@query)
|
||||||
|
@ -199,6 +204,7 @@ module Redmine
|
||||||
line_for_issue(i, options) unless options[:only] == :subjects
|
line_for_issue(i, options) unless options[:only] == :subjects
|
||||||
|
|
||||||
options[:top] += options[:top_increment]
|
options[:top] += options[:top_increment]
|
||||||
|
@number_of_rows += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -208,6 +214,7 @@ module Redmine
|
||||||
line_for_version(version, options) unless options[:only] == :subjects
|
line_for_version(version, options) unless options[:only] == :subjects
|
||||||
|
|
||||||
options[:top] += options[:top_increment]
|
options[:top] += options[:top_increment]
|
||||||
|
@number_of_rows += 1
|
||||||
|
|
||||||
# Remove the project requirement for Versions because it will
|
# Remove the project requirement for Versions because it will
|
||||||
# restrict issues to only be on the current project. This
|
# restrict issues to only be on the current project. This
|
||||||
|
|
Loading…
Reference in New Issue