Skip to content

Commit

Permalink
Small query optimizations / cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
glacials committed Oct 21, 2024
1 parent ee1b81e commit c73e3c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/views/layouts/application.slim
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ html lang='en'
small: #hide-survey-button.text-secondary style='cursor: pointer' no thanks
a#survey-button.btn.btn-outline-warning.btn-block.mb-0.text-center href=survey_url
' Help us out by taking the Splits.io survey!
- entry = current_user.present? ? current_user.entries.nonghosts.active.first : nil
- entry = current_user&.entries.nonghosts.active.first
- if entry.present? && request.path != race_path(entry.race)
.p-1.col-md-6.mx-auto
a.btn.btn-success.btn-block.mb-0.text-center.glow href=race_path(entry.race)
Expand All @@ -134,8 +134,8 @@ html lang='en'
= yield(:footer)
.row
.col-md-6.d-none.d-xl-block
- patrons = User.includes(:patreon, :twitch).joins(:patreon).where('patreon_users.pledge_cents >= 200')
- unless patrons.blank?
- patrons = Rails.cache.fetch('patrons', expires_in: 1.day) { User.includes(:patreon, :twitch).joins(:patreon).where('patreon_users.pledge_cents >= 200').all }
- unless patrons.empty?
a> href=patreon_url
span Thanks to our patrons!
p
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_run_table.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- description ||= nil
- cols ||= [:runner, :time, :name, :video, :rival, :uploaded]
/ This allows us to blindly check the keys for items instead of wraping in `try`s
/ This allows us to blindly check the keys for items instead of wrapping in `try`s
- col_options = cols.to_h { |col| [col, []] }.merge(local_assigns.fetch(:col_options, {}))
- runs = order_runs(runs).page(params[:page]).includes(:user, :game, :category, :video, :segments)
- runs = order_runs(runs).page(params[:page]).includes(:user, :video, :segments, :category, game: [:srdc])
- if runs.none?
- if description.present?
h5.card-header.text-white = description
Expand Down

0 comments on commit c73e3c5

Please sign in to comment.