diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6d8451cdc..bcdf10dff 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -299,20 +299,22 @@ class ProjectsController < ApplicationController events = @activity.events(@date_from, @date_to) - respond_to do |format| - format.html { - @events_by_day = events.group_by(&:event_date) - render :layout => false if request.xhr? - } - format.atom { - title = l(:label_activity) - if @author - title = @author.name - elsif @activity.scope.size == 1 - title = l("label_#{@activity.scope.first.singularize}_plural") - end - render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") - } + if events.empty? || stale?(:etag => [events.first, User.current]) + respond_to do |format| + format.html { + @events_by_day = events.group_by(&:event_date) + render :layout => false if request.xhr? + } + format.atom { + title = l(:label_activity) + if @author + title = @author.name + elsif @activity.scope.size == 1 + title = l("label_#{@activity.scope.first.singularize}_plural") + end + render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") + } + end end rescue ActiveRecord::RecordNotFound diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 1d0bd8a16..fb73d5d28 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -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