Skip to content

Commit

Permalink
temp: fix entitlements_to_expire should be capped at entitlements_cou…
Browse files Browse the repository at this point in the history
…nt (#32579)
  • Loading branch information
pshiu authored Jun 26, 2023
1 parent ddf8c32 commit 8072c3e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def handle(self, *args, **options):
entitlements_count = entitlements.count()
logger.info('Total entitlements that have reached expiration period are %d ', entitlements_count)

entitlements_to_expire = max(1, options.get('count'))
entitlements_to_expire = min(max(1, options.get('count')), entitlements_count)
batch_size = max(1, options.get('batch_size'))
num_batches = ceil(entitlements_to_expire / batch_size) if entitlements else 0

Expand All @@ -100,7 +100,7 @@ def handle(self, *args, **options):

for batch_num in range(num_batches):
start = batch_num * batch_size
end = min(start + batch_size, entitlements_to_expire, entitlements_count)
end = min(start + batch_size, entitlements_to_expire)
entitlement_ids = [entitlement.id for entitlement in entitlements[start:end]]
expire_and_create_entitlements.delay(entitlement_ids, support_username)

Expand Down

0 comments on commit 8072c3e

Please sign in to comment.