##// END OF EJS Templates
Added fragment caching for calendar and gantt views...
Jean-Philippe Lang -
r512:b748455d9664
parent child
Show More
@@ -0,0 +1,38
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 class IssueSweeper < ActionController::Caching::Sweeper
19 observe Issue
20
21 def after_save(issue)
22 expire_cache_for(issue)
23 end
24
25 def after_destroy(issue)
26 expire_cache_for(issue)
27 end
28
29 private
30 def expire_cache_for(issue)
31 # fragments of the main project
32 expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project_id}\\."))
33 # fragments of the root project that include subprojects issues
34 unless issue.project.parent_id.nil?
35 expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project.parent_id}\\..*subprojects"))
36 end
37 end
38 end
@@ -18,6 +18,8
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 layout 'base', :except => :export_pdf
19 layout 'base', :except => :export_pdf
20 before_filter :find_project, :authorize
20 before_filter :find_project, :authorize
21
22 cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
21
23
22 helper :custom_fields
24 helper :custom_fields
23 include CustomFieldsHelper
25 include CustomFieldsHelper
@@ -21,6 +21,8 class ProjectsController < ApplicationController
21 layout 'base'
21 layout 'base'
22 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
22 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
23 before_filter :require_admin, :only => [ :add, :destroy ]
23 before_filter :require_admin, :only => [ :add, :destroy ]
24
25 cache_sweeper :issue_sweeper, :only => [ :add_issue ]
24
26
25 helper :sort
27 helper :sort
26 include SortHelper
28 include SortHelper
@@ -1,3 +1,4
1 <% cache(:year => @year, :month => @month, :tracker_ids => @selected_tracker_ids, :subprojects => params[:with_subprojects], :lang => current_language) do %>
1 <h2><%= l(:label_calendar) %></h2>
2 <h2><%= l(:label_calendar) %></h2>
2
3
3 <% form_tag do %>
4 <% form_tag do %>
@@ -87,4 +88,5 end %>
87
88
88 <%= image_tag 'arrow_from.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_begin_day) %><br />
89 <%= image_tag 'arrow_from.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_begin_day) %><br />
89 <%= image_tag 'arrow_to.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_end_day) %><br />
90 <%= image_tag 'arrow_to.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_end_day) %><br />
90 <%= image_tag 'arrow_bw.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_begin_end_day) %><br /> No newline at end of file
91 <%= image_tag 'arrow_bw.png' %>&nbsp;&nbsp;<%= l(:text_tip_task_begin_end_day) %><br />
92 <% end %>
@@ -1,3 +1,28
1 <% zoom = 1
2 @zoom.times { zoom = zoom * 2 }
3
4 subject_width = 330
5 header_heigth = 18
6
7 headers_height = header_heigth
8 show_weeks = false
9 show_days = false
10
11 if @zoom >1
12 show_weeks = true
13 headers_height = 2*header_heigth
14 if @zoom > 2
15 show_days = true
16 headers_height = 3*header_heigth
17 end
18 end
19
20 g_width = (@date_to - @date_from + 1)*zoom
21 g_height = [(20 * @events.length + 6)+150, 206].max
22 t_height = g_height + headers_height
23 %>
24
25 <% cache(:year => @year_from, :month => @month_from, :months => @months, :zoom => @zoom, :tracker_ids => @selected_tracker_ids, :subprojects => params[:with_subprojects], :lang => current_language) do %>
1 <div class="contextual">
26 <div class="contextual">
2 <%= l(:label_export_to) %>
27 <%= l(:label_export_to) %>
3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
28 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
@@ -47,30 +72,6
47 </table>
72 </table>
48 <% end %>
73 <% end %>
49
74
50 <% zoom = 1
51 @zoom.times { zoom = zoom * 2 }
52
53 subject_width = 330
54 header_heigth = 18
55
56 headers_height = header_heigth
57 show_weeks = false
58 show_days = false
59
60 if @zoom >1
61 show_weeks = true
62 headers_height = 2*header_heigth
63 if @zoom > 2
64 show_days = true
65 headers_height = 3*header_heigth
66 end
67 end
68
69 g_width = (@date_to - @date_from + 1)*zoom
70 g_height = [(20 * @events.length + 6)+150, 206].max
71 t_height = g_height + headers_height
72 %>
73
74 <table width="100%" style="border:0; border-collapse: collapse;">
75 <table width="100%" style="border:0; border-collapse: collapse;">
75 <tr>
76 <tr>
76 <td style="width:<%= subject_width %>px;">
77 <td style="width:<%= subject_width %>px;">
@@ -173,14 +174,6 end %>
173
174
174 <%
175 <%
175 #
176 #
176 # Today red line
177 #
178 if Date.today >= @date_from and Date.today <= @date_to %>
179 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
180 <% end %>
181
182 <%
183 #
184 # Tasks
177 # Tasks
185 #
178 #
186 top = headers_height + 10
179 top = headers_height + 10
@@ -226,6 +219,18 top = headers_height + 10
226 <% end %>
219 <% end %>
227 <% top = top + 20
220 <% top = top + 20
228 end %>
221 end %>
222
223 <% end # cache
224 %>
225
226 <%
227 #
228 # Today red line (excluded from cache)
229 #
230 if Date.today >= @date_from and Date.today <= @date_to %>
231 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
232 <% end %>
233
229 </div>
234 </div>
230 </td>
235 </td>
231 </tr>
236 </tr>
@@ -236,4 +241,4 end %>
236 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
241 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
237 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
242 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
238 </tr>
243 </tr>
239 </table> No newline at end of file
244 </table>
@@ -13,8 +13,8 Rails::Initializer.run do |config|
13 # Skip frameworks you're not going to use
13 # Skip frameworks you're not going to use
14 # config.frameworks -= [ :action_web_service, :action_mailer ]
14 # config.frameworks -= [ :action_web_service, :action_mailer ]
15
15
16 # Add additional load paths for your own custom dirs
16 # Add additional load paths for sweepers
17 # config.load_paths += %W( #{RAILS_ROOT}/extras )
17 config.load_paths += %W( #{RAILS_ROOT}/app/sweepers )
18
18
19 # Force all environments to use the same logger level
19 # Force all environments to use the same logger level
20 # (by default production uses :info, the others :debug)
20 # (by default production uses :info, the others :debug)
General Comments 0
You need to be logged in to leave comments. Login now