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

[CHG] review product aggregation by backend to improve performance #9

Merged
merged 1 commit into from
Jul 26, 2017
Merged
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
9 changes: 5 additions & 4 deletions connector_magento/models/product/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ def recompute_magento_qty(self):
informations for each product.
"""
# group products by backend
backends = defaultdict(self.browse)
backends = defaultdict(set)
Copy link

@gurneyalex gurneyalex Jul 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guewen If you want to squeeze some more perfs out of this, make this defaultdict(list) and:

  • on line 113 use append instead of add
  • on line 117 below use self.browse(set(product_ids))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no.

for product in self:
backends[product.backend_id] |= product
backends[product.backend_id].add(product.id)

for backend, products in backends.iteritems():
self._recompute_magento_qty_backend(backend, products)
for backend, product_ids in backends.iteritems():
self._recompute_magento_qty_backend(backend,
self.browse(product_ids))
return True

@api.multi
Expand Down