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

@ -2,8 +2,7 @@
%li
%a.smoothscroll{ href: '#registration' } Registration
- cache [conference.registration_period, conference.tickets,
'#splash#registration'] do
- cache [conference, registration_period, tickets, '#splash#registration'] do
%section#registration
.container
.row
@ -12,23 +11,23 @@
- if conference.registration_limit_exceeded?
%p
Sorry, the conference registration limit has exceeded
- elsif conference.tickets.empty?
- elsif tickets.empty?
%p.lead
Going to
= conference.short_title
is free of charge.
%p
We only ask you to register yourself before
= date_string(conference.registration_period.end_date)
= date_string(registration_period.end_date)
so we can plan for the right amount of people.
%p.cta-button
- else
%p
The registration period is open
= date_string(conference.registration_period.start_date,
conference.registration_period.end_date)
= date_string(registration_period.start_date,
registration_period.end_date)
- if conference.registration_open?
%p.cta-button
= link_to('Register Now',
new_conference_conference_registration_path(conference.short_title),
new_conference_conference_registration_path(conference_id),
class: 'btn btn-lg btn-success')