fix object_search #22

Merged
v4l3n71n merged 1 commits from feature/search into master 2024-10-23 21:23:01 +00:00

View File

@ -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)