From 5a6fdfcbc39a80b57c81dc2cd1f0a7a549e9606d Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 16 Jan 2025 12:57:13 +0530 Subject: [PATCH] fix: simplfied logic to filter current day batches --- lms/lms/utils.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 93e7f207..6b7ed8dc 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1895,22 +1895,20 @@ def get_batches(filters=None, start=0, page_length=20, order_by="start_date"): def filter_batches_based_on_start_time(batches, filters): batchType = get_batch_type(filters) if batchType == "upcoming": - batches_to_remove = list( - filter( - lambda batch: getdate(batch.start_date) == getdate() - and get_time_str(batch.start_time) < nowtime(), - batches, - ) - ) + batches_to_remove = [ + batch + for batch in batches + if getdate(batch.start_date) == getdate() + and get_time_str(batch.start_time) < nowtime() + ] batches = [batch for batch in batches if batch not in batches_to_remove] elif batchType == "archived": - batches_to_remove = list( - filter( - lambda batch: getdate(batch.start_date) == getdate() - and get_time_str(batch.start_time) >= nowtime(), - batches, - ) - ) + batches_to_remove = [ + batch + for batch in batches + if getdate(batch.start_date) == getdate() + and get_time_str(batch.start_time) >= nowtime() + ] batches = [batch for batch in batches if batch not in batches_to_remove] return batches