mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Performance opt - cache AR Proxy for Version#fixed_issues.visible (#27676).
Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@17052 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
cd75ba33e9
commit
d0b10af3ff
@ -57,9 +57,9 @@ module VersionsHelper
|
||||
h = Hash.new {|k,v| k[v] = [0, 0]}
|
||||
begin
|
||||
# Total issue count
|
||||
version.fixed_issues.visible.group(criteria).count.each {|c,s| h[c][0] = s}
|
||||
version.visible_fixed_issues.group(criteria).count.each {|c,s| h[c][0] = s}
|
||||
# Open issues count
|
||||
version.fixed_issues.visible.open.group(criteria).count.each {|c,s| h[c][1] = s}
|
||||
version.visible_fixed_issues.open.group(criteria).count.each {|c,s| h[c][1] = s}
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# When grouping by an association, Rails throws this exception if there's no result (bug)
|
||||
end
|
||||
|
||||
@ -176,6 +176,7 @@ class Version < ActiveRecord::Base
|
||||
alias :base_reload :reload
|
||||
def reload(*args)
|
||||
@default_project_version = nil
|
||||
@visible_fixed_issues = nil
|
||||
base_reload(*args)
|
||||
end
|
||||
|
||||
@ -257,6 +258,10 @@ class Version < ActiveRecord::Base
|
||||
fixed_issues.closed_count
|
||||
end
|
||||
|
||||
def visible_fixed_issues
|
||||
@visible_fixed_issues ||= fixed_issues.visible
|
||||
end
|
||||
|
||||
def wiki_page
|
||||
if project.wiki && !wiki_page_title.blank?
|
||||
@wiki_page ||= project.wiki.find_page(wiki_page_title)
|
||||
|
||||
@ -14,22 +14,22 @@
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if version.fixed_issues.visible.count > 0 %>
|
||||
<%= progress_bar([version.fixed_issues.visible.closed_percent, version.fixed_issues.visible.completed_percent],
|
||||
<% if version.visible_fixed_issues.count > 0 %>
|
||||
<%= progress_bar([version.visible_fixed_issues.closed_percent, version.visible_fixed_issues.completed_percent],
|
||||
:titles =>
|
||||
["%s: %0.0f%%" % [l(:label_closed_issues_plural), version.fixed_issues.visible.closed_percent],
|
||||
"%s: %0.0f%%" % [l(:field_done_ratio), version.fixed_issues.visible.completed_percent]],
|
||||
:legend => ('%0.0f%%' % version.fixed_issues.visible.completed_percent)) %>
|
||||
["%s: %0.0f%%" % [l(:label_closed_issues_plural), version.visible_fixed_issues.closed_percent],
|
||||
"%s: %0.0f%%" % [l(:field_done_ratio), version.visible_fixed_issues.completed_percent]],
|
||||
:legend => ('%0.0f%%' % version.visible_fixed_issues.completed_percent)) %>
|
||||
<p class="progress-info">
|
||||
<%= link_to(l(:label_x_issues, :count => version.fixed_issues.visible.count),
|
||||
<%= link_to(l(:label_x_issues, :count => version.visible_fixed_issues.count),
|
||||
version_filtered_issues_path(version, :status_id => '*')) %>
|
||||
|
||||
(<%= link_to_if(version.fixed_issues.visible.closed_count > 0,
|
||||
l(:label_x_closed_issues_abbr, :count => version.fixed_issues.visible.closed_count),
|
||||
(<%= link_to_if(version.visible_fixed_issues.closed_count > 0,
|
||||
l(:label_x_closed_issues_abbr, :count => version.visible_fixed_issues.closed_count),
|
||||
version_filtered_issues_path(version, :status_id => 'c')) %>
|
||||
—
|
||||
<%= link_to_if(version.fixed_issues.visible.open_count > 0,
|
||||
l(:label_x_open_issues_abbr, :count => version.fixed_issues.visible.open_count),
|
||||
<%= link_to_if(version.visible_fixed_issues.open_count > 0,
|
||||
l(:label_x_open_issues_abbr, :count => version.visible_fixed_issues.open_count),
|
||||
version_filtered_issues_path(version, :status_id => 'o')) %>)
|
||||
</p>
|
||||
<% else %>
|
||||
|
||||
@ -12,12 +12,12 @@
|
||||
<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
|
||||
|
||||
<div id="version-summary">
|
||||
<% if @version.fixed_issues.visible.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
|
||||
<% if @version.visible_fixed_issues.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
|
||||
<fieldset class="time-tracking"><legend><%= l(:label_time_tracking) %></legend>
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= l(:field_estimated_hours) %></th>
|
||||
<td class="total-hours"><%= link_to html_hours(l_hours(@version.fixed_issues.visible.estimated_hours)),
|
||||
<td class="total-hours"><%= link_to html_hours(l_hours(@version.visible_fixed_issues.estimated_hours)),
|
||||
project_issues_path(@version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => @version.id, :c => [:tracker, :status, :subject, :estimated_hours], :t => [:estimated_hours]) %></td>
|
||||
</tr>
|
||||
<% if User.current.allowed_to_view_all_time_entries?(@project) %>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user