add current_time in list all events #27

Merged
v4l3n71n merged 1 commits from feature/listEventDate into master 2024-11-10 17:45:42 +00:00

View File

@ -22,6 +22,19 @@ async def read_events(authorize: Annotated[bool, Depends(permissions_checker.Per
listEvents = []
event_repository = events.EventRepository(database=database.database)
object_search = {}
if current_datetime is not None:
object_search ={
"$or": [{"start_date": {"$gte": current_datetime}}, # Upcoming events
{"$and": [ # Ongoing events
{"start_date": {"$lte": current_datetime}}, # Already started
{"$or": [
{"end_date": {"$gte": current_datetime}}, # End date in the future
{"end_date": None} # No end date set
]}
]}
]
}
if status is not 1:
object_search = {"status":{"$eq": status}}
if current_datetime is not None: