-
-
Couldn't load subscription status.
- Fork 199
Identify slow requests #2305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Identify slow requests #2305
Changes from all commits
7df6ae6
c32fef6
4ae2277
ddc4ecf
e98a783
7b26aa2
eb6e867
bbdda6a
e5f338b
3ec5ade
6976f0c
623829e
eb830ba
0a00234
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module AttendanceConcerns | ||
| extend ActiveSupport::Concern | ||
|
|
||
| def attending_workshops | ||
| current_user.nil? ? Set.new : current_user.workshop_invitations.accepted.pluck(:id).to_set | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Micro detail: the |
||
| end | ||
|
|
||
| def attending_events | ||
| current_user.nil? ? Set.new : current_user.invitations.accepted.pluck(:id).to_set | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| class MemberPresenter < BasePresenter | ||
|
|
||
| def organiser? | ||
| has_role? :organiser, :any | ||
| end | ||
|
|
||
| def is_admin? | ||
| @admin ||= has_role?(:admin) | ||
| end | ||
|
|
||
| # Gather all the ids of all the events the member has organised or has organising permissions for | ||
| def organising_events | ||
| @organised_events ||= roles.preload(:resource).where(name: 'organiser').pluck(:resource_type, :resource_id).group_by(&:first).transform_values { |pairs | pairs.map(&:last)} | ||
| end | ||
|
|
||
| def event_organiser?(event) | ||
| has_role?(:organiser, event) || has_role?(:organiser, event.chapter) || has_role?(:admin) | ||
| if model.nil? | ||
| false | ||
| else | ||
| event_types = %w[Workshop Meeting Event] | ||
| organising_events.slice(*event_types).values.any? { |ids| ids.include?(event.id) } || @organised_events['Chapter']&.include?(event.chapter.id) || is_admin? | ||
| end | ||
|
|
||
| end | ||
|
|
||
| def newbie? | ||
|
|
@@ -23,6 +39,8 @@ def pairing_details_array(role, tutorial, note) | |
| role.eql?('Coach') ? coach_pairing_details(note) : student_pairing_details(tutorial, note) | ||
| end | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these two spaces needed? |
||
|
|
||
| private | ||
|
|
||
| def coach_pairing_details(note) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,8 @@ | |
| - if @member.groups.any? | ||
| %h5 Groups | ||
| %ul.list-unstyled.ms-0#subscriptions | ||
| - @member.groups.each do |group| | ||
| - member_groups = @member.groups | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably just do |
||
| - member_groups.each do |group| | ||
| %li | ||
| = link_to [:admin, group] do | ||
| #{group.name} (#{group.chapter.name}) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,11 @@ | |
| - if event.chapter | ||
| %span.badge.bg-primary.mb-3.mb-md-0 | ||
| = link_to event.chapter.name, event.chapter.slug, class: 'text-light text-decoration-none' | ||
| - if @user | ||
| - if @user.attending?(event.__getobj__) | ||
| - if !attending_ids.blank? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - if attending_ids.include?(event.id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as you mentioned in the PR description, this seems problematic if there is a crossover of ids between different event types. |
||
| %span.badge.bg-success.mb-3.mb-md-0 | ||
| = link_to 'Attending', event.path, class: 'text-light text-decoration-none' | ||
| - if @user | ||
| - if @user.event_organiser?(event) | ||
| %span.badge.bg-secondary.mb-3.mb-md-0 | ||
| = link_to 'Manage', event.admin_path, class: 'text-light text-decoration-none' | ||
|
|
@@ -31,10 +32,12 @@ | |
| .d-md-flex.justify-content-md-between.align-items-md-center | ||
| - if event.organisers.any? | ||
| .mb-3.mb-md-0 | ||
| - event.organisers.each do |organiser| | ||
| - organisers = event.organisers | ||
| - organisers.each do |organiser| | ||
| = image_tag(organiser.avatar(26), class: 'rounded-circle', title: organiser.full_name, alt: organiser.full_name) | ||
| - if event.sponsors.any? | ||
| .ms-auto | ||
| - event.sponsors.each do |sponsor| | ||
| - sponsors = event.sponsors | ||
| - sponsors.each do |sponsor| | ||
| = link_to sponsor.website, class: 'd-inline-block' do | ||
| = image_tag(sponsor.avatar.thumb.url, class: 'sponsor-sm mx-1', alt: sponsor.name) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ | |
| %h3.h5= date | ||
| .row | ||
| .col-md-8 | ||
| = render workshops | ||
| = render workshops, attending_ids: attending_ids | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,11 @@ | |
| .col | ||
| - if @events.any? | ||
| %h3.mb-4 Upcoming Events | ||
| = render partial: 'events', locals: { grouped_events: @events } | ||
| = render partial: 'events', locals: { grouped_events: @events, attending_ids: @attending_ids} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need a space before the closing |
||
|
|
||
| .container{'data-test': 'past-events'} | ||
| .row | ||
| .col | ||
| - if @past_events.any? | ||
| %h3.mb-4 Past Events | ||
| = render partial: 'events', locals: { grouped_events: @past_events } | ||
| = render partial: 'events', locals: { grouped_events: @past_events, attending_ids: @attending_ids } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| = render partial: 'events/event', locals: { event: workshop } | ||
| = render partial: 'events/event', locals: { event: workshop, attending_ids: attending_ids } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is one concern I think this should just be AttendanceConcern same for the file name so it matches the following: