Features: 1) Add initialization for filter_kwargs in delete_inactives method;
Fixes: 1) Streamline queryset filtering in `delete_inactives` by removing redundant line breaks; Extra: 1) Minor formatting cleanup for improved code readability;
This commit is contained in:
parent
95cd868ebd
commit
68db25e022
1 changed files with 2 additions and 3 deletions
5
core/vendors/__init__.py
vendored
5
core/vendors/__init__.py
vendored
|
|
@ -301,6 +301,7 @@ class AbstractVendor:
|
||||||
raise ValueError(f"Invalid method {method!r} for products update...")
|
raise ValueError(f"Invalid method {method!r} for products update...")
|
||||||
|
|
||||||
def delete_inactives(self, inactivation_method: str = "deactivate", size: int = 5000):
|
def delete_inactives(self, inactivation_method: str = "deactivate", size: int = 5000):
|
||||||
|
filter_kwargs: dict[str, Any] = {}
|
||||||
# noinspection PyUnreachableCode
|
# noinspection PyUnreachableCode
|
||||||
match inactivation_method:
|
match inactivation_method:
|
||||||
case "deactivate":
|
case "deactivate":
|
||||||
|
|
@ -311,9 +312,7 @@ class AbstractVendor:
|
||||||
raise ValueError(f"Invalid method {inactivation_method!r} for products cleaner...")
|
raise ValueError(f"Invalid method {inactivation_method!r} for products cleaner...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
batch_ids = list(self.get_products_queryset()
|
batch_ids = list(self.get_products_queryset().filter(**filter_kwargs).values_list("pk", flat=True)[:size])
|
||||||
.filter(**filter_kwargs)
|
|
||||||
.values_list("pk", flat=True)[:size])
|
|
||||||
if not batch_ids:
|
if not batch_ids:
|
||||||
break
|
break
|
||||||
with suppress(Exception):
|
with suppress(Exception):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue