Optimisation to eager load regions when outputting events
This commit is contained in:
parent
76f0a33145
commit
c60f6f4db3
|
@ -87,6 +87,7 @@ class EventsController < ApplicationController
|
||||||
# The 3000 limit is purely arbitrary...
|
# The 3000 limit is purely arbitrary...
|
||||||
@events = apply_scopes Event.moderated.order('id desc')
|
@events = apply_scopes Event.moderated.order('id desc')
|
||||||
.limit(params[:format] == 'rss' ? 20 : 3000)
|
.limit(params[:format] == 'rss' ? 20 : 3000)
|
||||||
|
@events = @events.includes :region if params[:format].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions
|
# Use callbacks to share common setup or constraints between actions
|
||||||
|
|
Loading…
Reference in New Issue