Optimisation to eager load regions when outputting events

This commit is contained in:
echarp 2019-02-27 14:05:55 +00:00
parent 76f0a33145
commit c60f6f4db3
1 changed files with 1 additions and 0 deletions

View File

@ -87,6 +87,7 @@ class EventsController < ApplicationController
# The 3000 limit is purely arbitrary...
@events = apply_scopes Event.moderated.order('id desc')
.limit(params[:format] == 'rss' ? 20 : 3000)
@events = @events.includes :region if params[:format].present?
end
# Use callbacks to share common setup or constraints between actions