add current_time in list all events #27
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user