From 20b4e226fe06db9132eccafd9f3c2c008ec99c09 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 3 Oct 2007 17:20:04 +0000 Subject: [PATCH] Performance improvement on calendar and gantt (about 45% on gantt for large number of issues). Partial issues/_tooltip is replaced by an helper and some translated strings are now cached. git-svn-id: http://redmine.rubyforge.org/svn/trunk@794 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 1 + app/controllers/timelog_controller.rb | 1 + app/helpers/application_helper.rb | 4 ++-- app/helpers/issues_helper.rb | 13 +++++++++++++ app/views/issues/_tooltip.rhtml | 6 ------ app/views/projects/calendar.rhtml | 2 +- app/views/projects/gantt.rhtml | 2 +- app/views/timelog/details.rhtml | 4 ++-- 8 files changed, 21 insertions(+), 12 deletions(-) delete mode 100644 app/views/issues/_tooltip.rhtml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 892d03911..d2d132458 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -34,6 +34,7 @@ class ProjectsController < ApplicationController include CustomFieldsHelper helper :ifpdf include IfpdfHelper + helper :issues helper IssuesHelper helper :queries include QueriesHelper diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 1c15fa564..68c0edefa 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -21,6 +21,7 @@ class TimelogController < ApplicationController helper :sort include SortHelper + helper :issues def report @available_criterias = { 'version' => {:sql => "#{Issue.table_name}.fixed_version_id", diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e52d1492e..6f6458650 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,8 +70,8 @@ module ApplicationHelper def format_date(date) return nil unless date - @date_format_setting ||= Setting.date_format.to_i - @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d") + @date_format ||= (Setting.date_format.to_i == 0 ? l(:general_fmt_date) : date.strftime("%Y-%m-%d")) + date.strftime(@date_format) end def format_time(time) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 8ef1de8f7..997f094a4 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -17,6 +17,19 @@ module IssuesHelper + def render_issue_tooltip(issue) + @cached_label_start_date ||= l(:field_start_date) + @cached_label_due_date ||= l(:field_due_date) + @cached_label_assigned_to ||= l(:field_assigned_to) + @cached_label_priority ||= l(:field_priority) + + link_to_issue(issue) + ": #{h(issue.subject)}

" + + "#{@cached_label_start_date}: #{format_date(issue.start_date)}
" + + "#{@cached_label_due_date}: #{format_date(issue.due_date)}
" + + "#{@cached_label_assigned_to}: #{issue.assigned_to}
" + + "#{@cached_label_priority}: #{issue.priority.name}" + end + def show_detail(detail, no_html=false) case detail.property when 'attr' diff --git a/app/views/issues/_tooltip.rhtml b/app/views/issues/_tooltip.rhtml deleted file mode 100644 index de0330fb0..000000000 --- a/app/views/issues/_tooltip.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= link_to_issue issue %>: <%=h issue.subject %>
-
-<%= l(:field_start_date) %>: <%= format_date(issue.start_date) %>
-<%= l(:field_due_date) %>: <%= format_date(issue.due_date) %>
-<%= l(:field_assigned_to) %>: <%= issue.assigned_to ? issue.assigned_to.name : "-" %>
-<%= l(:field_priority) %>: <%= issue.priority.name %> diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml index ad022f303..b6f2958f3 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -49,7 +49,7 @@ while day <= @date_to <%= h(truncate(i.subject, 30)) %> - <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> + <%= render_issue_tooltip i %> <% else %> diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml index d3b3167fc..75e5b9fc5 100644 --- a/app/views/projects/gantt.rhtml +++ b/app/views/projects/gantt.rhtml @@ -192,7 +192,7 @@ top = headers_height + 10 <% # === tooltip === %>
- <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> + <%= render_issue_tooltip i %>
<% else i_left = ((i.start_date - @date_from)*zoom).floor diff --git a/app/views/timelog/details.rhtml b/app/views/timelog/details.rhtml index 5683a2f3f..ac647c3a5 100644 --- a/app/views/timelog/details.rhtml +++ b/app/views/timelog/details.rhtml @@ -29,9 +29,9 @@ <% if entry.issue %>
- <%= link_to "#{entry.issue.tracker.name} ##{entry.issue.id}", {:action => 'details', :issue_id => entry.issue } %> + <%= link_to_issue entry.issue %> - <%= render :partial => "issues/tooltip", :locals => { :issue => entry.issue }%> + <%= render_issue_tooltip entry.issue %>
<% end %>