Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork198
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This removes a call to '#attending?' for every workshop, instead creating a single method to generate the list.Running locally with a small sample, it reduced loading time for the homepage by 70%Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
This now checks if the object passed to the Presenter is `nil` and responds accordingly. I've updated the logic in the dashboard_controller.rb to reflect the changeSigned-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
There feels like a lot of repetition here, but I can't figure out how to remove it right nowSigned-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
In order to use the MemberPresenter more flexibly, I want to remove the constant checking. The Presenter should be able to intialise with a `nil` object and then deal with the consequences of that. This approach will return `false` to any method not defined on the presenter or the presented object.Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
Current count: 16 failures.Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
This reverts commitf909f8b.
Apply the method across the events area, in the same way we did for workshopsSigned-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
f65f4da toe5f338bCompareCurrently we call `event_organiser` on every event when creating the dashboard. I've rewritten it to cache some of the things a user might be an organiser of.Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
We don't need to check if a user is admin every single time, so I've cached the checkSigned-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
We don't need to load each chapter separately - let's get them all in one!Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
jonodrew commentedAug 24, 2025
In total, this cuts loading the front page down to below 4s |
Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
| @@ -0,0 +1,13 @@ | |||
| # frozen_string_literal: true | |||
| moduleAttendanceConcerns | |||
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:
- Rails autoloading expectations
- ActiveSupport::Concern conventions
- The rails generate concern behaviour
davidmillen50 commentedAug 25, 2025
I'm interested to know more about the savings you hope to make. I just loaded the production front page in 3.42s will your changes reduce that? |
| 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 comment
The reason will be displayed to describe this comment to others.Learn more.
are these two spaces needed?
| = 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 comment
The reason will be displayed to describe this comment to others.Learn more.
attending_ids.present? might be better here
| - 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 comment
The reason will be displayed to describe this comment to others.Learn more.
I think you need a space before the closing}
| %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 comment
The reason will be displayed to describe this comment to others.Learn more.
I'd probably just do@member.groups.each etc
| - if@user | ||
| - if@user.attending?(event.__getobj__) | ||
| - if!attending_ids.blank? | ||
| - ifattending_ids.include?(event.id) |
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 you mentioned in the PR description, this seems problematic if there is a crossover of ids between different event types.
| extendActiveSupport::Concern | ||
| defattending_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 comment
The reason will be displayed to describe this comment to others.Learn more.
Micro detail: theids method -https://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-ids
Uh oh!
There was an error while loading.Please reload this page.
I'm not completely happy with this yet.
I've written some helper methods to grab all of the 'things' a member is attending and find them once, when the controller method is called. This replaces the map loop that generated two queries per event.
However, I think there's some clash here. The set of Event, Meeting, and Workshop ids will have some overlap and the tests will therefore be flakey. Advice welcome