Improve performance of admin/conference/*/registrations
* Add some caching * Reduce query count, including N+1s on questions & roles
This commit is contained in:
parent
6987c34e12
commit
66ea7c077d
5 changed files with 66 additions and 65 deletions
|
|
@ -32,54 +32,60 @@
|
|||
%abbr{ title: 'Code of Conduct' } CoC
|
||||
%th Arrival
|
||||
%th Departure
|
||||
- if @conference.questions.any?
|
||||
- if @questions.any?
|
||||
%th Questions
|
||||
%th Actions
|
||||
%tbody
|
||||
- @registrations.each_with_index do |registration, index|
|
||||
%tr
|
||||
%td
|
||||
= registration.id
|
||||
%td
|
||||
= registration.name.present? ? registration.name : registration.username
|
||||
%br
|
||||
- registration.user.roles.where(resource: @conference).each do |role|
|
||||
%span.label.label-info
|
||||
= role.name.titleize
|
||||
%td
|
||||
= registration.email
|
||||
- if @code_of_conduct
|
||||
- if registration.accepted_code_of_conduct
|
||||
%td.text-success.text-center= fa_icon('check', title: 'accepted')
|
||||
- else
|
||||
%td.text-center.text-warning
|
||||
= fa_icon('exclamation-circle',
|
||||
title: 'Has not accepted Code of Conduct')
|
||||
%td
|
||||
- if registration.arrival
|
||||
= registration.arrival.strftime('%d %b %H:%M')
|
||||
- else
|
||||
n/a
|
||||
%td
|
||||
- if registration.departure
|
||||
= registration.departure.strftime('%d %b %H:%M')
|
||||
- else
|
||||
n/a
|
||||
-if @conference.questions.any?
|
||||
- cache [:admin, registration, registration.user] do
|
||||
%tr
|
||||
%td
|
||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||
%td{ 'data-order' => registration.attended.to_s }
|
||||
= check_box_tag "#{@conference.short_title}_#{registration.id}", registration.id, registration.attended,
|
||||
class: 'switch-checkbox',
|
||||
url: toggle_attendance_admin_conference_registration_path(@conference.short_title, id: registration.id)+"?attended="
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
||||
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the Registration for #{registration.name}?" }
|
||||
- @registrations.each_with_index do |registration, index|
|
||||
.questions{class: "question#{index}", style: 'display:none;'}
|
||||
= render partial: 'questions', locals: { registration: registration }
|
||||
= registration.id
|
||||
%td
|
||||
= registration.name.present? ? registration.name : registration.username
|
||||
%b
|
||||
- registration.user.roles.select{|r| r.resource == @conference}.each do |role|
|
||||
%span.label.label-info
|
||||
= role.name.titleize
|
||||
%td
|
||||
= registration.email
|
||||
- if @code_of_conduct
|
||||
- if registration.accepted_code_of_conduct
|
||||
%td.text-success.text-center= fa_icon('check', title: 'accepted')
|
||||
- else
|
||||
%td.text-center.text-warning
|
||||
= fa_icon('exclamation-circle',
|
||||
title: 'Has not accepted Code of Conduct')
|
||||
%td
|
||||
- if registration.arrival
|
||||
= registration.arrival.strftime('%d %b %H:%M')
|
||||
- else
|
||||
n/a
|
||||
%td
|
||||
- if registration.departure
|
||||
= registration.departure.strftime('%d %b %H:%M')
|
||||
- else
|
||||
n/a
|
||||
-if @questions.any?
|
||||
%td
|
||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||
%td{ 'data-order' => registration.attended.to_s }
|
||||
= check_box_tag "#{@conference.short_title}_#{registration.id}", registration.id, registration.attended,
|
||||
class: 'switch-checkbox', method: :patch,
|
||||
url: toggle_attendance_admin_conference_registration_path(@conference.short_title, id: registration.id)+"?attended=",
|
||||
data: { size: 'small',
|
||||
on_color: 'success',
|
||||
off_color: 'warning',
|
||||
on_text: 'Present',
|
||||
off_text: 'Absent' }
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
||||
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the Registration for #{registration.name}?" }
|
||||
- @registrations.each_with_index do |registration, index|
|
||||
.questions{class: "question#{index}", style: 'display:none;'}
|
||||
= render partial: 'questions', locals: { registration: registration }
|
||||
|
||||
.modal.fade{ id: 'questions', 'role' => 'dialog', 'aria-hidden' => 'true' }
|
||||
.modal-dialog
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue