Add etag check on the activity view to avoid rendering when not modified.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2982 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-10-25 17:27:24 +00:00
parent 06fff6295c
commit a658679d29
2 changed files with 19 additions and 15 deletions

View File

@ -299,6 +299,7 @@ class ProjectsController < ApplicationController
events = @activity.events(@date_from, @date_to)
if events.empty? || stale?(:etag => [events.first, User.current])
respond_to do |format|
format.html {
@events_by_day = events.group_by(&:event_date)
@ -314,6 +315,7 @@ class ProjectsController < ApplicationController
render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
}
end
end
rescue ActiveRecord::RecordNotFound
render_404

View File

@ -66,6 +66,7 @@ module Redmine
end
# Returns an array of events for the given date range
# sorted in reverse chronological order
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
@ -76,8 +77,9 @@ module Redmine
end
end
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
if options[:limit]
e.sort! {|a,b| b.event_date <=> a.event_date}
e = e.slice(0, options[:limit])
end
e