Skip to content
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

Tentative optimisation for index slow down #73

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/blueprints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show

def index
set_filters
general_scope = policy_scope(Blueprint)
general_scope = policy_scope(Blueprint.light_query_scope)
.joins(:collection)
.where(collection: { type: "Public" })

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/blueprints_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def filter(blueprints)
if @filters[:color].present? && @filters[:color_similarity].present?
# TODO: Create real scopes and not this horrible thing
@filters[:filtered_for] = :mechas
blueprint_ids = colors_by_hsl(@filters[:color], @filters[:color_similarity]).pluck("blueprint_mecha_colors.blueprint_id")
blueprint_ids = colors_by_hsl(@filters[:color], @filters[:color_similarity]).joins(:blueprint_mecha_colors).select("blueprint_mecha_colors.blueprint_id")
blueprints = blueprints.where(id: blueprint_ids)
end

Expand Down
1 change: 1 addition & 0 deletions app/models/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Blueprint < ApplicationRecord

# Hides other mods as long as we don't have a need for them
default_scope { includes(:mod, :tags, :tag_taggings, :user).where(mod: { name: "Dyson Sphere Program" }) }
light_query_scope { select(column_names - ['encoded_blueprint']) }

pg_search_scope :search_by_title,
against: [:title],
Expand Down
2 changes: 2 additions & 0 deletions config/scout_apm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
production:
auto_instruments: true