mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fewer queries for for Conference#show
Reduces SQL wait times by >90% on splash pages.
This commit is contained in:
parent
29a640a267
commit
995176ffe5
11 changed files with 122 additions and 99 deletions
|
|
@ -9,19 +9,44 @@ class ConferencesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@conference = if params[:id]
|
@conference = Conference.unscoped.eager_load(
|
||||||
Conference.find_by_short_title(params[:id])
|
:organization,
|
||||||
else
|
:splashpage,
|
||||||
load_conference_by_domain
|
:venue,
|
||||||
end
|
:registration_period,
|
||||||
|
:tickets,
|
||||||
|
:confirmed_tracks,
|
||||||
|
:call_for_events,
|
||||||
|
:event_types,
|
||||||
|
:program,
|
||||||
|
:call_for_tracks,
|
||||||
|
:lodgings,
|
||||||
|
:call_for_booths,
|
||||||
|
:confirmed_booths,
|
||||||
|
:sponsors,
|
||||||
|
:call_for_sponsors,
|
||||||
|
:contact,
|
||||||
|
highlighted_events: [:speakers],
|
||||||
|
sponsorship_levels: [:sponsors]
|
||||||
|
).order(
|
||||||
|
'sponsorship_levels.position ASC',
|
||||||
|
'sponsors.name',
|
||||||
|
'tracks.name',
|
||||||
|
'booths.title',
|
||||||
|
'lodgings.name',
|
||||||
|
'tickets.price_cents'
|
||||||
|
).find_by(conference_finder_conditions)
|
||||||
authorize! :show, @conference
|
authorize! :show, @conference
|
||||||
@program = @conference.program
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_conference_by_domain
|
def conference_finder_conditions
|
||||||
Conference.find_by(custom_domain: request.domain)
|
if params[:id]
|
||||||
|
{ short_title: params[:id] }
|
||||||
|
else
|
||||||
|
{ custom_domain: request.domain }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_options
|
def respond_to_options
|
||||||
|
|
|
||||||
|
|
@ -56,17 +56,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def tracks(conference)
|
def tracks(conference)
|
||||||
all = conference.program.tracks.confirmed.cfp_active.pluck(:name)
|
conference.confirmed_tracks.collect(&:name).to_sentence
|
||||||
first = all[0...-1]
|
|
||||||
last = all[-1]
|
|
||||||
ts = ''
|
|
||||||
if all.length > 1
|
|
||||||
ts << first.join(', ')
|
|
||||||
ts << " and #{last}"
|
|
||||||
else
|
|
||||||
ts = all.join
|
|
||||||
end
|
|
||||||
ts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def difficulty_levels(conference)
|
def difficulty_levels(conference)
|
||||||
|
|
@ -152,7 +142,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def event_types(conference)
|
def event_types(conference)
|
||||||
conference.program.event_types.map { |et| et.title.pluralize }.to_sentence
|
conference.event_types.map { |et| et.title.pluralize }.to_sentence
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in_path
|
def sign_in_path
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class Conference < ApplicationRecord
|
||||||
end
|
end
|
||||||
has_many :resources, dependent: :destroy
|
has_many :resources, dependent: :destroy
|
||||||
has_many :booths, dependent: :destroy
|
has_many :booths, dependent: :destroy
|
||||||
|
has_many :confirmed_booths, -> { where(state: 'confirmed') }, class_name: 'Booth'
|
||||||
|
|
||||||
has_many :lodgings, dependent: :destroy
|
has_many :lodgings, dependent: :destroy
|
||||||
has_many :registrations, dependent: :destroy
|
has_many :registrations, dependent: :destroy
|
||||||
|
|
@ -45,7 +46,16 @@ class Conference < ApplicationRecord
|
||||||
has_many :campaigns, dependent: :destroy
|
has_many :campaigns, dependent: :destroy
|
||||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||||
has_many :subscriptions, dependent: :destroy
|
has_many :subscriptions, dependent: :destroy
|
||||||
|
has_one :call_for_sponsors, -> { where(cfp_type: 'sponsors') }, through: :program, source: :cfps
|
||||||
|
has_one :call_for_events, -> { where(cfp_type: 'events') }, through: :program, source: :cfps
|
||||||
|
has_one :call_for_booths, -> { where(cfp_type: 'booths') }, through: :program, source: :cfps
|
||||||
|
has_one :call_for_tracks, -> { where(cfp_type: 'tracks') }, through: :program, source: :cfps
|
||||||
|
has_many :confirmed_tracks, -> { where(state: 'confirmed') }, through: :program, source: :tracks
|
||||||
|
has_many :highlighted_events,
|
||||||
|
-> { where(state: :confirmed, is_highlight: true) },
|
||||||
|
through: :program,
|
||||||
|
source: :events
|
||||||
|
has_many :event_types, through: :program
|
||||||
accepts_nested_attributes_for :venue
|
accepts_nested_attributes_for :venue
|
||||||
accepts_nested_attributes_for :tickets, allow_destroy: true
|
accepts_nested_attributes_for :tickets, allow_destroy: true
|
||||||
accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true
|
accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12.text-center
|
||||||
%h2 Booths
|
%h2 Booths
|
||||||
- @conference.booths.confirmed.each_slice(3).with_index do |slice, index_for_row|
|
- @conference.confirmed_booths.each_slice(3).with_index do |slice, index_for_row|
|
||||||
.row.row-centered
|
.row.row-centered
|
||||||
- slice.each.with_index do |booth, index_for_column|
|
- slice.each.with_index do |booth, index_for_column|
|
||||||
.col-md-4.col-sm-4.col-xs-10.col-centered.col-top
|
.col-md-4.col-sm-4.col-xs-10.col-centered.col-top
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
%h3.text-center
|
%h3.text-center
|
||||||
= booth.title
|
= booth.title
|
||||||
%p.text-center.text-muted
|
%p.text-center.text-muted
|
||||||
= link_to "#show_descrition_#{index_for_row}_#{index_for_column}", "data-toggle"=>"collapse" do
|
= link_to "#show_description_#{index_for_row}_#{index_for_column}", "data-toggle"=>"collapse" do
|
||||||
learn more
|
learn more
|
||||||
.collapse{ id: "show_descrition_#{index_for_row}_#{index_for_column}" }
|
.collapse{ id: "show_description_#{index_for_row}_#{index_for_column}" }
|
||||||
= markdown(booth.description)
|
= markdown(booth.description)
|
||||||
|
|
|
||||||
|
|
@ -12,32 +12,34 @@
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1
|
.col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1
|
||||||
%p
|
%p
|
||||||
- if @conference.program.event_types.any?
|
- if @conference.event_types.any?
|
||||||
You can submit proposals for
|
You can submit proposals for
|
||||||
%span.notranslate
|
%span.notranslate
|
||||||
= "#{event_types(@conference)}."
|
= "#{event_types(@conference)}."
|
||||||
- if @conference.program.tracks.any?
|
- if @conference.confirmed_tracks.any?
|
||||||
Proposals should fit in one of the
|
Proposals should fit in one of the
|
||||||
%span.notranslate
|
%span.notranslate
|
||||||
= "#{pluralize(@conference.program.tracks.count, 'track')}:"
|
= "#{pluralize(@conference.confirmed_tracks.length, 'track')}:"
|
||||||
= "#{tracks(@conference)}."
|
= "#{tracks(@conference)}."
|
||||||
The submission period has begun
|
- if @conference.call_for_events.try(:open?)
|
||||||
%em.notranslate
|
The submission period is open
|
||||||
= @conference.program.cfp.start_date.strftime('%A, %B %-d. %Y')
|
%em.notranslate
|
||||||
and closes
|
= "#{date_string(@conference.call_for_events.start_date,
|
||||||
%em.notranslate
|
@conference.call_for_events.end_date)}."
|
||||||
= @conference.program.cfp.end_date.strftime('%A, %B %-d. %Y.')
|
%b
|
||||||
- if @conference.program.cfp_open?
|
You have
|
||||||
That means you have only
|
= pluralize(@conference.call_for_events.remaining_days, 'day')
|
||||||
%b.notranslate= pluralize(@conference.program.cfp.remaining_days, 'day')
|
left!
|
||||||
left!
|
|
||||||
Remember
|
Remember
|
||||||
%span.notranslate
|
%span.notranslate
|
||||||
= @conference.short_title
|
= @conference.title
|
||||||
will only be as good as the sessions you present. Submit early, submit often!
|
will only be as good as the sessions you present.
|
||||||
|
Submit early, submit often!
|
||||||
- else
|
- else
|
||||||
The submission period is closed.
|
The submission period is closed.
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12.text-center
|
||||||
%p.cta-button
|
%p.cta-button
|
||||||
= link_to "Submit your paper now", conference_program_proposals_path(@conference.short_title), class: 'btn btn-success btn-lg text-center'
|
= link_to "Submit your paper now",
|
||||||
|
conference_program_proposals_path(@conference.short_title),
|
||||||
|
class: 'btn btn-success btn-lg text-center'
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,17 @@
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1
|
.col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1
|
||||||
%p
|
%p
|
||||||
The submission period for track requests has begun
|
The submission period for track requests is open
|
||||||
%em.notranslate
|
%em.notranslate
|
||||||
= @conference.program.cfps.for_tracks.start_date.strftime('%A, %B %-d. %Y')
|
= "#{date_string(@conference.call_for_tracks.start_date,
|
||||||
and closes
|
@conference.call_for_tracks.end_date)}."
|
||||||
%em.notranslate
|
%b
|
||||||
= @conference.program.cfps.for_tracks.end_date.strftime('%A, %B %-d. %Y.')
|
You have
|
||||||
- if @conference.program.cfps.for_tracks.try(:open?)
|
= pluralize(@conference.call_for_tracks.remaining_days, 'day')
|
||||||
That means you have only
|
|
||||||
%b.notranslate= pluralize(@conference.program.cfps.for_tracks.remaining_days, 'day')
|
|
||||||
left!
|
left!
|
||||||
- else
|
|
||||||
The submission period for track requests is closed.
|
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12.text-center
|
||||||
%p.cta-button
|
%p.cta-button
|
||||||
= link_to "Submit your request for track", conference_program_tracks_path(@conference.short_title), class: 'btn btn-success btn-lg text-center'
|
= link_to("Submit your request for track",
|
||||||
|
conference_program_tracks_path(@conference.short_title),
|
||||||
|
class: 'btn btn-success btn-lg text-center')
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
%p.lead
|
%p.lead
|
||||||
We recommend these affordable lodging accommodations for your visit.
|
We recommend these affordable lodging accommodations for your visit.
|
||||||
|
|
||||||
.row.row-centered{ style:"display: flex; flex-wrap: wrap" }
|
.row.row-centered
|
||||||
- @conference.lodgings.each do |lodging|
|
- @conference.lodgings.each do |lodging|
|
||||||
.col-md-4.col-sm-4.col-centered.col-top{ style:"display:flex;" }
|
.col-md-4.col-sm-4.col-centered.col-top
|
||||||
.thumbnail
|
.thumbnail
|
||||||
- if lodging.picture?
|
- if lodging.picture?
|
||||||
-if lodging.website_link.present?
|
-if lodging.website_link.present?
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
%i.fa.fa-home.fa-5x
|
%i.fa.fa-home.fa-5x
|
||||||
- else
|
- else
|
||||||
%i.fa.fa-home.fa-5x
|
%i.fa.fa-home.fa-5x
|
||||||
.caption
|
.caption
|
||||||
%h3.text-center
|
%h3.text-center
|
||||||
= lodging.name
|
= lodging.name
|
||||||
-if lodging.description.present?
|
-if lodging.description.present?
|
||||||
= markdown(lodging.description)
|
= markdown(lodging.description)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
= content_for :splash_nav do
|
||||||
|
%li
|
||||||
|
=link_to('#program', class: 'smoothscroll') do
|
||||||
|
Program
|
||||||
|
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
@ -5,43 +10,41 @@
|
||||||
Program
|
Program
|
||||||
%p.lead.text-center
|
%p.lead.text-center
|
||||||
%span.notranslate
|
%span.notranslate
|
||||||
= @conference.short_title
|
= @conference.title
|
||||||
has the most awesome program ever!
|
has the most awesome program ever!
|
||||||
- if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks
|
- if @conference.splashpage.include_tracks && @conference.confirmed_tracks.any?
|
||||||
See rock-star speakers cover the topics of
|
See rock-star speakers cover the topics of
|
||||||
- if @conference.splashpage and @conference.splashpage.include_tracks
|
- @conference.confirmed_tracks.each_slice(3) do |slice|
|
||||||
- @conference.program.tracks.confirmed.each_slice(3) do |slice|
|
.row.row-centered
|
||||||
.row.row-centered
|
- slice.each do |track|
|
||||||
- slice.each do |track|
|
.col-md-4.col-sm-4.col-centered.col-top.track
|
||||||
.col-md-4.col-sm-4.col-centered.col-top.track
|
%h4.text-center
|
||||||
%h4.text-center
|
= track.name
|
||||||
= track.name
|
= markdown(track.description)
|
||||||
= markdown(track.description)
|
- if track.start_date
|
||||||
- if track.start_date
|
%br
|
||||||
%br
|
From: #{track.start_date.strftime('%A, %B %-d. %Y')}
|
||||||
From: #{track.start_date.strftime('%A, %B %-d. %Y')}
|
- if track.end_date
|
||||||
- if track.end_date
|
%br
|
||||||
%br
|
To: #{track.end_date.strftime('%A, %B %-d. %Y')}
|
||||||
To: #{track.end_date.strftime('%A, %B %-d. %Y')}
|
- if track.room
|
||||||
- if track.room
|
%br
|
||||||
%br
|
In: #{track.room.name}
|
||||||
In: #{track.room.name}
|
|
||||||
|
|
||||||
- if @conference.program and @conference.program.schedule_public
|
- if @conference.program.try(:schedule_public?)
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%p.cta-button.text-center
|
%p.cta-button.text-center
|
||||||
= link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do
|
= link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do
|
||||||
Full Schedule
|
Full Schedule
|
||||||
|
|
||||||
|
|
||||||
%h3.text-center
|
%h3.text-center
|
||||||
Don't miss out!
|
Don't miss out!
|
||||||
%br
|
%br
|
||||||
- if @conference.program.events.highlights.any?
|
- if @conference.highlighted_events.any?
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
- @conference.program.events.highlights.each_slice(2) do |slice|
|
- @conference.highlighted_events.each_slice(2) do |slice|
|
||||||
.row.row-centered
|
.row.row-centered
|
||||||
- slice.each do |event|
|
- slice.each do |event|
|
||||||
.col-md-6.col-centered.col-top.highlights
|
.col-md-6.col-centered.col-top.highlights
|
||||||
|
|
@ -50,8 +53,3 @@
|
||||||
%h5.text-center
|
%h5.text-center
|
||||||
= markdown truncate(event.abstract, length: 500, separator: ' ')
|
= markdown truncate(event.abstract, length: 500, separator: ' ')
|
||||||
= link_to "Read More", conference_program_proposal_path(@conference.short_title, event)
|
= link_to "Read More", conference_program_proposal_path(@conference.short_title, event)
|
||||||
|
|
||||||
= content_for :splash_nav do
|
|
||||||
%li
|
|
||||||
=link_to('#program', class: 'smoothscroll') do
|
|
||||||
Program
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
= sponsor.description
|
= sponsor.description
|
||||||
.modal-footer
|
.modal-footer
|
||||||
= link_to nil, "#{sponsor.website_url}", target: '_blank'
|
= link_to nil, "#{sponsor.website_url}", target: '_blank'
|
||||||
-if @conference.contact and !@conference.contact.sponsor_email.blank?
|
- if @conference.call_for_sponsors.try(:open?)
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%p.text-muted.text-center
|
%p.text-muted.text-center
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
%h3.text-center
|
%h3.text-center
|
||||||
= markdown(@conference.description)
|
= markdown(@conference.description)
|
||||||
|
|
||||||
- if @conference.registration_open? and @conference.splashpage.include_registrations
|
- if @conference.splashpage.include_registrations && @conference.registration_open?
|
||||||
%section#registration
|
%section#registration
|
||||||
= render 'registration'
|
= render 'registration'
|
||||||
|
|
||||||
|
|
@ -45,35 +45,35 @@
|
||||||
%section#program
|
%section#program
|
||||||
= render 'schedule_splashpage'
|
= render 'schedule_splashpage'
|
||||||
|
|
||||||
- if @conference.program.cfp_open? and @conference.splashpage.include_cfp
|
- if @conference.splashpage.include_cfp && @conference.call_for_events.try(:open?)
|
||||||
%section#callforpapers
|
%section#callforpapers
|
||||||
= render 'call_for_paper'
|
= render 'call_for_paper'
|
||||||
|
|
||||||
- if @conference.program.cfps.for_tracks.try(:open?) && @conference.splashpage.include_cfp
|
- if @conference.splashpage.include_cfp && @conference.call_for_tracks.try(:open?)
|
||||||
%section#callfortracks
|
%section#callfortracks
|
||||||
= render 'call_for_tracks'
|
= render 'call_for_tracks'
|
||||||
|
|
||||||
- if @conference.venue and @conference.splashpage.include_venue
|
- if @conference.splashpage.include_venue && @conference.venue
|
||||||
%section#venue
|
%section#venue
|
||||||
= render 'venue'
|
= render 'venue'
|
||||||
|
|
||||||
- if @conference.lodgings.any? and @conference.splashpage.include_lodgings
|
- if @conference.splashpage.include_lodgings && @conference.lodgings.any?
|
||||||
%section#lodging
|
%section#lodging
|
||||||
= render 'lodging'
|
= render 'lodging'
|
||||||
|
|
||||||
- if @conference.tickets.any? and @conference.splashpage.include_tickets and @conference.pending?
|
- if @conference.splashpage.include_tickets && @conference.tickets.any? && @conference.pending?
|
||||||
%section#tickets
|
%section#tickets
|
||||||
= render 'tickets'
|
= render 'tickets'
|
||||||
|
|
||||||
- if @conference.booths.confirmed.any? and @conference.splashpage.include_booths
|
- if @conference.splashpage.include_booths && @conference.confirmed_booths.any?
|
||||||
%section#booths
|
%section#booths
|
||||||
= render 'booths'
|
= render 'booths'
|
||||||
|
|
||||||
- if @conference.sponsors.any? and @conference.splashpage.include_sponsors
|
- if @conference.splashpage.include_sponsors && @conference.sponsors.any?
|
||||||
%section#sponsors
|
%section#sponsors
|
||||||
= render 'sponsors'
|
= render 'sponsors'
|
||||||
|
|
||||||
- if @conference.contact.has_social_media? and @conference.splashpage.include_social_media
|
- if @conference.splashpage.include_social_media && @conference.contact.has_social_media?
|
||||||
%section#social-media
|
%section#social-media
|
||||||
= render 'social_media'
|
= render 'social_media'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
= link_to(edit_user_path(current_user.id)) do
|
= link_to(edit_user_path(current_user.id)) do
|
||||||
%span.fa.fa-user
|
%span.fa.fa-user
|
||||||
Edit Profile
|
Edit Profile
|
||||||
-if @conference and @conference.program
|
-if @conference && @conference.program
|
||||||
%li
|
%li
|
||||||
= link_to(conference_program_proposals_path(@conference.short_title)) do
|
= link_to(conference_program_proposals_path(@conference.short_title)) do
|
||||||
%span.fa.fa-comment
|
%span.fa.fa-comment
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
= link_to(conference_program_tracks_path(@conference.short_title)) do
|
= link_to(conference_program_tracks_path(@conference.short_title)) do
|
||||||
%span.fa.fa-road
|
%span.fa.fa-road
|
||||||
My Tracks
|
My Tracks
|
||||||
-if @conference && @conference.program && (@conference.program.cfps.for_booths.try(:open?) || current_user.booths.where(conference_id: @conference.id).count > 0)
|
-if @conference && (@conference.call_for_booths.try(:open?) || current_user.booths.where(conference_id: @conference.id).count > 0)
|
||||||
%li
|
%li
|
||||||
= link_to (conference_booths_path(@conference.short_title)) do
|
= link_to (conference_booths_path(@conference.short_title)) do
|
||||||
%span.fa.fa-shopping-bag
|
%span.fa.fa-shopping-bag
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
=link_to(new_admin_conference_path) do
|
=link_to(new_admin_conference_path) do
|
||||||
%span.fa.fa-plus
|
%span.fa.fa-plus
|
||||||
New Conference
|
New Conference
|
||||||
-if @conference and @conference.id and can? :show, @conference
|
-if @conference && @conference.id && can?(:show, @conference)
|
||||||
%li
|
%li
|
||||||
= link_to(admin_conference_path(@conference.short_title)) do
|
= link_to(admin_conference_path(@conference.short_title)) do
|
||||||
%span.fa.fa-cog
|
%span.fa.fa-cog
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue