@spree/docs 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -131,7 +131,7 @@ The `ProductPresenter` returns an array of documents. For a store with US (USD/E
|
|
|
131
131
|
|
|
132
132
|
## Step 4: Implement Bulk Reindex
|
|
133
133
|
|
|
134
|
-
Use `
|
|
134
|
+
Use `preload_associations_lazily` to avoid N+1 queries:
|
|
135
135
|
|
|
136
136
|
```ruby app/models/my_app/search_provider/typesense.rb
|
|
137
137
|
def reindex(scope = nil)
|
|
@@ -139,9 +139,9 @@ def reindex(scope = nil)
|
|
|
139
139
|
ensure_index_settings!
|
|
140
140
|
|
|
141
141
|
scope.reorder(id: :asc)
|
|
142
|
-
.
|
|
142
|
+
.preload_associations_lazily
|
|
143
143
|
.find_in_batches(batch_size: 500) do |batch|
|
|
144
|
-
documents = batch.flat_map { |p|
|
|
144
|
+
documents = batch.flat_map { |p| presenter_class.new(p, store).call }
|
|
145
145
|
index_batch(documents)
|
|
146
146
|
end
|
|
147
147
|
end
|