Revision 1157
Added by Jean-Philippe Lang over 17 years ago
trunk/app/controllers/issues_controller.rb | ||
---|---|---|
25 | 25 |
before_filter :authorize, :except => [:index, :changes, :preview, :update_form, :context_menu] |
26 | 26 |
before_filter :find_optional_project, :only => [:index, :changes] |
27 | 27 |
accept_key_auth :index, :changes |
28 |
|
|
29 |
cache_sweeper :issue_sweeper, :only => [ :new, :edit, :bulk_edit, :destroy ] |
|
30 | 28 |
|
31 | 29 |
helper :journals |
32 | 30 |
helper :projects |
trunk/app/controllers/projects_controller.rb | ||
---|---|---|
29 | 29 |
before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] |
30 | 30 |
accept_key_auth :activity, :calendar |
31 | 31 |
|
32 |
cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] |
|
33 |
cache_sweeper :version_sweeper, :only => [ :add_version ] |
|
34 |
|
|
35 | 32 |
helper :sort |
36 | 33 |
include SortHelper |
37 | 34 |
helper :custom_fields |
trunk/app/controllers/versions_controller.rb | ||
---|---|---|
20 | 20 |
menu_item :roadmap |
21 | 21 |
before_filter :find_project, :authorize |
22 | 22 |
|
23 |
cache_sweeper :version_sweeper, :only => [ :edit, :destroy ] |
|
24 |
|
|
25 | 23 |
def show |
26 | 24 |
end |
27 | 25 |
|
trunk/app/sweepers/version_sweeper.rb | ||
---|---|---|
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 VersionSweeper < ActionController::Caching::Sweeper |
|
19 |
observe Version |
|
20 |
|
|
21 |
def after_save(version) |
|
22 |
expire_cache_for(version) |
|
23 |
end |
|
24 |
|
|
25 |
def after_destroy(version) |
|
26 |
expire_cache_for(version) |
|
27 |
end |
|
28 |
|
|
29 |
private |
|
30 |
def expire_cache_for(version) |
|
31 |
# calendar and gantt fragments of the project |
|
32 |
expire_fragment(Regexp.new("projects/(calendar|gantt)/#{version.project_id}\\.")) |
|
33 |
end |
|
34 |
end |
|
35 | 0 |
trunk/app/sweepers/issue_sweeper.rb | ||
---|---|---|
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 |
|
39 | 0 |
trunk/app/sweepers/project_sweeper.rb | ||
---|---|---|
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 ProjectSweeper < ActionController::Caching::Sweeper |
|
19 |
observe Project |
|
20 |
|
|
21 |
def before_save(project) |
|
22 |
if project.new_record? |
|
23 |
expire_cache_for(project.parent) if project.parent |
|
24 |
else |
|
25 |
project_before_update = Project.find(project.id) |
|
26 |
return if project_before_update.parent_id == project.parent_id && project_before_update.status == project.status |
|
27 |
expire_cache_for(project.parent) if project.parent |
|
28 |
expire_cache_for(project_before_update.parent) if project_before_update.parent |
|
29 |
end |
|
30 |
end |
|
31 |
|
|
32 |
def after_destroy(project) |
|
33 |
expire_cache_for(project.parent) if project.parent |
|
34 |
end |
|
35 |
|
|
36 |
private |
|
37 |
def expire_cache_for(project) |
|
38 |
expire_fragment(Regexp.new("projects/(calendar|gantt)/#{project.id}\\.")) |
|
39 |
end |
|
40 |
end |
trunk/app/views/projects/calendar.rhtml | ||
---|---|---|
1 |
<% cache(:year => @year, :month => @month, :tracker_ids => @selected_tracker_ids, :subprojects => params[:with_subprojects], :lang => current_language) do %> |
|
2 | 1 |
<h2><%= "#{month_name(@month)} #{@year}" %></h2> |
3 | 2 |
|
4 | 3 |
<table width="100%"> |
... | ... | |
20 | 19 |
<%= image_tag 'arrow_from.png' %> <%= l(:text_tip_task_begin_day) %><br /> |
21 | 20 |
<%= image_tag 'arrow_to.png' %> <%= l(:text_tip_task_end_day) %><br /> |
22 | 21 |
<%= image_tag 'arrow_bw.png' %> <%= l(:text_tip_task_begin_end_day) %><br /> |
23 |
<% end %> |
|
24 | 22 |
|
25 | 23 |
<% content_for :sidebar do %> |
26 | 24 |
<h3><%= l(:label_calendar) %></h3> |
trunk/app/views/projects/gantt.rhtml | ||
---|---|---|
55 | 55 |
</table> |
56 | 56 |
<% end %> |
57 | 57 |
|
58 |
<% cache(:year => @year_from, :month => @month_from, :months => @months, :zoom => @zoom, :tracker_ids => @selected_tracker_ids, :subprojects => params[:with_subprojects], :lang => current_language) do %> |
|
59 |
|
|
60 | 58 |
<table width="100%" style="border:0; border-collapse: collapse;"> |
61 | 59 |
<tr> |
62 | 60 |
<td style="width:<%= subject_width %>px;"> |
... | ... | |
205 | 203 |
<% top = top + 20 |
206 | 204 |
end %> |
207 | 205 |
|
208 |
<% end # cache |
|
209 |
%> |
|
210 |
|
|
211 | 206 |
<% |
212 | 207 |
# |
213 | 208 |
# Today red line (excluded from cache) |
Also available in: Unified diff
Removed fragment caching on gantt and calendar.