fix: start date and target date issue filter (#525)

This commit is contained in:
pablohashescobar 2023-03-25 11:14:16 +05:30 committed by GitHub
parent 5152deb2d0
commit 31624f3ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,16 +121,16 @@ def filter_start_date(params, filter, method):
for query in start_dates: for query in start_dates:
start_date_query = query.split(";") start_date_query = query.split(";")
if len(start_date_query) == 2 and "after" in start_date_query: if len(start_date_query) == 2 and "after" in start_date_query:
filter["start_date__date__gte"] = start_date_query[0] filter["start_date__gte"] = start_date_query[0]
else: else:
filter["start_date__date__lte"] = start_date_query[0] filter["start_date__lte"] = start_date_query[0]
else: else:
if params.get("start_date", None) and len(params.get("start_date")): if params.get("start_date", None) and len(params.get("start_date")):
for query in params.get("start_date"): for query in params.get("start_date"):
if query.get("timeline", "after") == "after": if query.get("timeline", "after") == "after":
filter["start_date__date__gte"] = query.get("datetime") filter["start_date__gte"] = query.get("datetime")
else: else:
filter["start_date__date__lte"] = query.get("datetime") filter["start_date__lte"] = query.get("datetime")
return filter return filter
@ -141,16 +141,16 @@ def filter_target_date(params, filter, method):
for query in target_dates: for query in target_dates:
target_date_query = query.split(";") target_date_query = query.split(";")
if len(target_date_query) == 2 and "after" in target_date_query: if len(target_date_query) == 2 and "after" in target_date_query:
filter["target_date__date__gte"] = target_date_query[0] filter["target_date__gte"] = target_date_query[0]
else: else:
filter["target_date__date__lte"] = target_date_query[0] filter["target_date__lte"] = target_date_query[0]
else: else:
if params.get("target_date", None) and len(params.get("target_date")): if params.get("target_date", None) and len(params.get("target_date")):
for query in params.get("target_date"): for query in params.get("target_date"):
if query.get("timeline", "after") == "after": if query.get("timeline", "after") == "after":
filter["target_date__date__gte"] = query.get("datetime") filter["target_date__gte"] = query.get("datetime")
else: else:
filter["target_date__date__lte"] = query.get("datetime") filter["target_date__lte"] = query.get("datetime")
return filter return filter