fix: issue date filtering (#1834)

This commit is contained in:
Nikhil 2023-08-11 12:48:30 +05:30 committed by GitHub
parent edaeae1b69
commit def10af1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,10 +124,11 @@ def filter_created_at(params, filter, method):
else: else:
if params.get("created_at", None) and len(params.get("created_at")): if params.get("created_at", None) and len(params.get("created_at")):
for query in params.get("created_at"): for query in params.get("created_at"):
if query.get("timeline", "after") == "after": created_at_query = query.split(";")
filter["created_at__date__gte"] = query.get("datetime") if len(created_at_query) == 2 and "after" in created_at_query:
filter["created_at__date__gte"] = created_at_query[0]
else: else:
filter["created_at__date__lte"] = query.get("datetime") filter["created_at__date__lte"] = created_at_query[0]
return filter return filter
@ -144,10 +145,11 @@ def filter_updated_at(params, filter, method):
else: else:
if params.get("updated_at", None) and len(params.get("updated_at")): if params.get("updated_at", None) and len(params.get("updated_at")):
for query in params.get("updated_at"): for query in params.get("updated_at"):
if query.get("timeline", "after") == "after": updated_at_query = query.split(";")
filter["updated_at__date__gte"] = query.get("datetime") if len(updated_at_query) == 2 and "after" in updated_at_query:
filter["updated_at__date__gte"] = updated_at_query[0]
else: else:
filter["updated_at__date__lte"] = query.get("datetime") filter["updated_at__date__lte"] = updated_at_query[0]
return filter return filter
@ -164,10 +166,11 @@ def filter_start_date(params, filter, method):
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": start_date_query = query.split(";")
filter["start_date__gte"] = query.get("datetime") if len(start_date_query) == 2 and "after" in start_date_query:
filter["start_date__gte"] = start_date_query[0]
else: else:
filter["start_date__lte"] = query.get("datetime") filter["start_date__lte"] = start_date_query[0]
return filter return filter
@ -184,10 +187,11 @@ def filter_target_date(params, filter, method):
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": target_date_query = query.split(";")
filter["target_date__gt"] = query.get("datetime") if len(target_date_query) == 2 and "after" in target_date_query:
filter["target_date__gt"] = target_date_query[0]
else: else:
filter["target_date__lt"] = query.get("datetime") filter["target_date__lt"] = target_date_query[0]
return filter return filter
@ -205,10 +209,11 @@ def filter_completed_at(params, filter, method):
else: else:
if params.get("completed_at", None) and len(params.get("completed_at")): if params.get("completed_at", None) and len(params.get("completed_at")):
for query in params.get("completed_at"): for query in params.get("completed_at"):
if query.get("timeline", "after") == "after": completed_at_query = query.split(";")
filter["completed_at__date__gte"] = query.get("datetime") if len(completed_at_query) == 2 and "after" in completed_at_query:
filter["completed_at__date__gte"] = completed_at_query[0]
else: else:
filter["completed_at__lte"] = query.get("datetime") filter["completed_at__lte"] = completed_at_query[0]
return filter return filter