Break up the one-query-of-doom

The single query was producing a tremendously large ActiveRecord allocation.

While this isn't nearly as cool as one query, it's still a significant
reduction in SQL trips, and now has the bonus of only loading what is
actually going to be displayed.
This commit is contained in:
James Mason 2017-12-21 19:06:36 -08:00
parent 754d201b01
commit fa55224163
26 changed files with 181 additions and 165 deletions

View file

@ -1,8 +1,7 @@
module ConferenceHelper
# Return true if only call_for_papers or call_for_tracks is open
def one_call_open(conference)
conference.call_for_events.try(:open?) ^
conference.call_for_tracks.try(:open?)
def one_call_open(*calls)
calls.one? { |call| call.try(:open?) }
end
# URL for sponsorship emails