refactored conferences controller, dividing responsabilities using an service and an query
This commit is contained in:
parent
fd01351a92
commit
7b48daba07
6 changed files with 354 additions and 46 deletions
32
app/services/queries/conferences.rb
Normal file
32
app/services/queries/conferences.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class Queries::Conferences
|
||||
def initialize(conference: nil)
|
||||
@conference = conference
|
||||
end
|
||||
|
||||
def self.conference_by_filter(conference_finder_conditions)
|
||||
Conference.unscoped.eager_load(
|
||||
:splashpage,
|
||||
:program,
|
||||
:registration_period,
|
||||
:contact,
|
||||
venue: :commercial
|
||||
).find_by!(conference_finder_conditions)
|
||||
end
|
||||
|
||||
def sponsorship_levels
|
||||
conference.sponsorship_levels.eager_load(
|
||||
:sponsors
|
||||
).order('sponsorship_levels.position ASC', 'sponsors.name')
|
||||
end
|
||||
|
||||
def confirmed_tracks
|
||||
conference.confirmed_tracks.eager_load(
|
||||
:room
|
||||
).order('tracks.name')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr :conference
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue