Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add composite indexes for page queries. raise ActiveRecord::RecordNotFound.

Matthew Kennedy8b518d80fe38
diff --git a/core/db/migrate/20210512191732_create_spree_cms_pages.rb b/core/db/migrate/20210512191732_create_spree_cms_pages.rb
index 59925acbc9..e086b2443a 100644
--- a/core/db/migrate/20210512191732_create_spree_cms_pages.rb
+++ b/core/db/migrate/20210512191732_create_spree_cms_pages.rb
@@ -14,6 +14,9 @@ class CreateSpreeCmsPages < ActiveRecord::Migration[5.2]
t.timestamps
end
- add_index :spree_cms_pages, :slug
+
+ add_index :spree_cms_pages, [:title, :type, :store_id]
+ add_index :spree_cms_pages, [:slug, :store_id]
+ add_index :spree_cms_pages, [:store_id, :locale, :type]
end
end
diff --git a/core/db/migrate/20210514204251_create_spree_cms_sections.rb b/core/db/migrate/20210514204251_create_spree_cms_sections.rb
index 21d23b2267..23660add6b 100644
--- a/core/db/migrate/20210514204251_create_spree_cms_sections.rb
+++ b/core/db/migrate/20210514204251_create_spree_cms_sections.rb
@@ -19,6 +19,7 @@ class CreateSpreeCmsSections < ActiveRecord::Migration[5.2]
t.timestamps
end
+
add_index :spree_cms_sections, :position
end
end
diff --git a/frontend/app/controllers/spree/cms_pages_controller.rb b/frontend/app/controllers/spree/cms_pages_controller.rb
index 07095f6241..703a8069f0 100644
--- a/frontend/app/controllers/spree/cms_pages_controller.rb
+++ b/frontend/app/controllers/spree/cms_pages_controller.rb
@@ -11,6 +11,8 @@ module Spree
elsif try_spree_current_user&.admin?
@cms_page = @page
@edit_mode = true
+ else
+ raise ActiveRecord::RecordNotFound
end
end