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...")
|
||||
|
||||
def delete_inactives(self, inactivation_method: str = "deactivate", size: int = 5000):
|
||||
filter_kwargs: dict[str, Any] = {}
|
||||
# noinspection PyUnreachableCode
|
||||
match inactivation_method:
|
||||
case "deactivate":
|
||||
|
|
@ -311,9 +312,7 @@ class AbstractVendor:
|
|||
raise ValueError(f"Invalid method {inactivation_method!r} for products cleaner...")
|
||||
|
||||
while True:
|
||||
batch_ids = list(self.get_products_queryset()
|
||||
.filter(**filter_kwargs)
|
||||
.values_list("pk", flat=True)[:size])
|
||||
batch_ids = list(self.get_products_queryset().filter(**filter_kwargs).values_list("pk", flat=True)[:size])
|
||||
if not batch_ids:
|
||||
break
|
||||
with suppress(Exception):
|
||||
|
|
|
|||
Loading…
Reference in a new issue