Commit a658679d authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

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
parent 06fff629
...@@ -299,20 +299,22 @@ class ProjectsController < ApplicationController ...@@ -299,20 +299,22 @@ class ProjectsController < ApplicationController
events = @activity.events(@date_from, @date_to) events = @activity.events(@date_from, @date_to)
respond_to do |format| if events.empty? || stale?(:etag => [events.first, User.current])
format.html { respond_to do |format|
@events_by_day = events.group_by(&:event_date) format.html {
render :layout => false if request.xhr? @events_by_day = events.group_by(&:event_date)
} render :layout => false if request.xhr?
format.atom { }
title = l(:label_activity) format.atom {
if @author title = l(:label_activity)
title = @author.name if @author
elsif @activity.scope.size == 1 title = @author.name
title = l("label_#{@activity.scope.first.singularize}_plural") elsif @activity.scope.size == 1
end title = l("label_#{@activity.scope.first.singularize}_plural")
render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") end
} render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
}
end
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
......
...@@ -66,6 +66,7 @@ module Redmine ...@@ -66,6 +66,7 @@ module Redmine
end end
# Returns an array of events for the given date range # Returns an array of events for the given date range
# sorted in reverse chronological order
def events(from = nil, to = nil, options={}) def events(from = nil, to = nil, options={})
e = [] e = []
@options[:limit] = options[:limit] @options[:limit] = options[:limit]
...@@ -76,8 +77,9 @@ module Redmine ...@@ -76,8 +77,9 @@ module Redmine
end end
end end
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
if options[:limit] if options[:limit]
e.sort! {|a,b| b.event_date <=> a.event_date}
e = e.slice(0, options[:limit]) e = e.slice(0, options[:limit])
end end
e e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment