Skip to content

Commit

Permalink
[IMP] shopinvader_cart_expiry: improve job
Browse files Browse the repository at this point in the history
Improve the job in charge of unlink old carts by adding an identity key (to avoid having too much jobs who are doing the same cleaning on the same backend)
  • Loading branch information
acsonefho committed Jun 11, 2024
1 parent 2f22c7a commit f4c86fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def migrate(cr, version):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
domain = [("cart_expiry_delay", ">", 0)]
for backend in env.search(domain):
for backend in env["shopinvader.backend"].search(domain):
backend = backend.with_company(backend.company_id.id).sudo_tech()
expiry_date = fields.Datetime.from_string(fields.Datetime.now())
delta_arg = {backend.cart_expiry_delay_unit: backend.cart_expiry_delay}
Expand Down
5 changes: 4 additions & 1 deletion shopinvader_cart_expiry/models/shopinvader_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def _scheduler_manage_cart_expiry(self, domain=False):
domain = expression.AND([domain, [("cart_expiry_delay", ">", 0)]])
for backend in self.search(domain):
description = _("Manage cart expired for backend %s") % backend.name
backend.with_delay(description=description).manage_cart_expiry()
backend.with_delay(
description=description,
identity_key="shopinvader_manage_cart_expiry_%s" % (str(backend.id),),
).manage_cart_expiry()

def _get_cart_expiry_delay_domain(self):
expiry_date = fields.Datetime.from_string(fields.Datetime.now())
Expand Down

0 comments on commit f4c86fb

Please sign in to comment.