forked from wyeworks/nucore-open
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#148409] Reduce number of DB queries on Facility timeline page (wyew…
…orks#1899) * Refactor away Timelinable module The indirection and hack (in ReservationsController, public_timeline calls timeline) here are not worth the DRY aspect, and the two pages are very different, so decoupling their implementation allows us to evolve and optimize the controller methods separately as it makes sense. * Separate facility and public schedule partials and get rid of conditional * Refactor association-like methods on Schedule to associations * Use .size on association in _schedule so we don’t have to execute a count every time * Eliminate N+1 for loading alerts when displaying timelines * Fold single-use partial _relay_switch into only call site * Avoid N+1 for relays on facility timeline * Avoid two unnecessary queries just to check if an instrument is offline The method #offline? needs to check whether there are any current offline reservations. By refactoring to an association and using #present?, Rails will memoize the association and check without another DB query. * Appease rubocop’s style preferences
- Loading branch information
1 parent
01a9acc
commit f9a18c9
Showing
17 changed files
with
46 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...views/shared/timeline/_schedule.html.haml → ...facility_reservations/_schedule.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
- products = public_timeline? ? schedule.publicly_visible_products : schedule.facility_visible_products | ||
- if products.count > 1 | ||
- if schedule.facility_visible_products.size > 1 | ||
.timeline-schedule | ||
%h3= schedule.name | ||
= render partial: "shared/timeline/instrument", collection: products, as: :instrument | ||
= render partial: "shared/timeline/instrument", collection: schedule.facility_visible_products, as: :instrument | ||
- else | ||
.timeline-single | ||
= render partial: "shared/timeline/instrument", collection: products, as: :instrument | ||
= render partial: "shared/timeline/instrument", collection: schedule.facility_visible_products, as: :instrument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- if schedule.publicly_visible_products.size > 1 | ||
.timeline-schedule | ||
%h3= schedule.name | ||
= render partial: "shared/timeline/instrument", collection: schedule.publicly_visible_products, as: :instrument | ||
- else | ||
.timeline-single | ||
= render partial: "shared/timeline/instrument", collection: schedule.publicly_visible_products, as: :instrument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters