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

@ -6,7 +6,7 @@ describe ConferenceHelper, type: :helper do
describe '#one_call_open' do
it 'is falsey if neither call is open' do
expect(one_call_open(conference)).to be_falsey
expect(one_call_open(*conference.program.cfps)).to be_falsey
end
it 'is truthy if call_for_papers is open' do
@ -17,8 +17,7 @@ describe ConferenceHelper, type: :helper do
start_date: conference.start_date,
end_date: conference.end_date
)
expect(one_call_open(conference)).to be_truthy
expect(one_call_open(*conference.program.cfps)).to be_truthy
end
it 'is truthy if call_for_tracks is open' do
@ -30,7 +29,7 @@ describe ConferenceHelper, type: :helper do
end_date: conference.end_date
)
expect(one_call_open(conference)).to be_truthy
expect(one_call_open(*conference.program.cfps)).to be_truthy
end
it 'is falsey if both calls are open' do
@ -49,7 +48,7 @@ describe ConferenceHelper, type: :helper do
end_date: conference.end_date
)
expect(one_call_open(conference)).to be_falsey
expect(one_call_open(*conference.program.cfps)).to be_falsey
end
end