fix: simplfied logic to filter current day batches
This commit is contained in:
@@ -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):
|
def filter_batches_based_on_start_time(batches, filters):
|
||||||
batchType = get_batch_type(filters)
|
batchType = get_batch_type(filters)
|
||||||
if batchType == "upcoming":
|
if batchType == "upcoming":
|
||||||
batches_to_remove = list(
|
batches_to_remove = [
|
||||||
filter(
|
batch
|
||||||
lambda batch: getdate(batch.start_date) == getdate()
|
for batch in batches
|
||||||
and get_time_str(batch.start_time) < nowtime(),
|
if getdate(batch.start_date) == getdate()
|
||||||
batches,
|
and get_time_str(batch.start_time) < nowtime()
|
||||||
)
|
]
|
||||||
)
|
|
||||||
batches = [batch for batch in batches if batch not in batches_to_remove]
|
batches = [batch for batch in batches if batch not in batches_to_remove]
|
||||||
elif batchType == "archived":
|
elif batchType == "archived":
|
||||||
batches_to_remove = list(
|
batches_to_remove = [
|
||||||
filter(
|
batch
|
||||||
lambda batch: getdate(batch.start_date) == getdate()
|
for batch in batches
|
||||||
and get_time_str(batch.start_time) >= nowtime(),
|
if getdate(batch.start_date) == getdate()
|
||||||
batches,
|
and get_time_str(batch.start_time) >= nowtime()
|
||||||
)
|
]
|
||||||
)
|
|
||||||
batches = [batch for batch in batches if batch not in batches_to_remove]
|
batches = [batch for batch in batches if batch not in batches_to_remove]
|
||||||
return batches
|
return batches
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user