##// END OF EJS Templates
Add etag check on the activity view to avoid rendering when not modified....
Jean-Philippe Lang -
r2868:a658679d29eb
parent child
Show More
@@ -299,20 +299,22 class ProjectsController < ApplicationController
299
299
300 events = @activity.events(@date_from, @date_to)
300 events = @activity.events(@date_from, @date_to)
301
301
302 respond_to do |format|
302 if events.empty? || stale?(:etag => [events.first, User.current])
303 format.html {
303 respond_to do |format|
304 @events_by_day = events.group_by(&:event_date)
304 format.html {
305 render :layout => false if request.xhr?
305 @events_by_day = events.group_by(&:event_date)
306 }
306 render :layout => false if request.xhr?
307 format.atom {
307 }
308 title = l(:label_activity)
308 format.atom {
309 if @author
309 title = l(:label_activity)
310 title = @author.name
310 if @author
311 elsif @activity.scope.size == 1
311 title = @author.name
312 title = l("label_#{@activity.scope.first.singularize}_plural")
312 elsif @activity.scope.size == 1
313 end
313 title = l("label_#{@activity.scope.first.singularize}_plural")
314 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
314 end
315 }
315 render_feed(events, :title => "#{@project || Setting.app_title}: #{title}")
316 }
317 end
316 end
318 end
317
319
318 rescue ActiveRecord::RecordNotFound
320 rescue ActiveRecord::RecordNotFound
@@ -66,6 +66,7 module Redmine
66 end
66 end
67
67
68 # Returns an array of events for the given date range
68 # Returns an array of events for the given date range
69 # sorted in reverse chronological order
69 def events(from = nil, to = nil, options={})
70 def events(from = nil, to = nil, options={})
70 e = []
71 e = []
71 @options[:limit] = options[:limit]
72 @options[:limit] = options[:limit]
@@ -76,8 +77,9 module Redmine
76 end
77 end
77 end
78 end
78
79
80 e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
81
79 if options[:limit]
82 if options[:limit]
80 e.sort! {|a,b| b.event_date <=> a.event_date}
81 e = e.slice(0, options[:limit])
83 e = e.slice(0, options[:limit])
82 end
84 end
83 e
85 e
General Comments 0
You need to be logged in to leave comments. Login now