From a1e135a03ee706a3ad965c96c43ad0197659500d Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 23 Oct 2024 23:22:05 +0200 Subject: [PATCH] fix object_search --- app/routers/events.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/routers/events.py b/app/routers/events.py index be93b40..3bec5aa 100644 --- a/app/routers/events.py +++ b/app/routers/events.py @@ -53,8 +53,18 @@ async def search_events(authorize: Annotated[bool, Depends(permissions_checker.P event_repository = events.EventRepository(database=database.database) object_search = {} if item is not None: - object_search = { "$and": [{"$or":[{"name":{"$regex": item}}, {"tags":{"$regex":item}},{"organizers":{"$regex": item}}]},{"status":{"$eq":status}}]} - + object_search = { + "$and": [ + { + "$or": [ + {"name": {"$regex": item}}, + {"tags": {"$regex": item}}, + {"organizers": {"$regex": item}} + ] + }, + {"status": {"$eq": status}} + ] + } for event_index in event_repository.find_by(object_search, limit=limit, skip=skip): event = events.EventOut(id=event_index.id, tags=event_index.tags, imgUrl=event_index.imgUrl, name=event_index.name, description=event_index.description, place=event_index.place, zip_code=event_index.zip_code, city=event_index.city, country=event_index.country, status=event_index.status, start_date=event_index.start_date, end_date=event_index.end_date) listEvents.append(event)