Skip to content
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
20 changes: 17 additions & 3 deletions erpnext/accounts/doctype/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,25 @@ def get_prorata_factor(period_end, period_start, is_prepaid):

def process_all():
"""
Task to updates the status of all `Subscription` apart from those that are cancelled
Task to updates the status of all `Subscription` apart from those that are cancelled.
Subscriptions are split into batches and each batch is enqueued as a separate background job.
"""
from frappe.utils import create_batch
subscriptions = get_all_subscriptions()
for subscription in subscriptions:
process(subscription)
for subscription in create_batch(subscriptions, 200):
frappe.enqueue(
'erpnext.accounts.doctype.subscription.subscription.process_batch',
batch=subscription,
queue='long',
)


def process_batch(batch):
"""
Process a batch of subscriptions sequentially.
"""
for data in batch:
process(data)


def get_all_subscriptions():
Expand Down
Loading