From 2b16ae3bb65d7f0ae3b96eb13b7a678bf39be4ac0e5bb2fdf743ce0392eda0b1 Mon Sep 17 00:00:00 2001 From: vladislav Date: Mon, 17 Aug 2026 13:48:37 -0400 Subject: [PATCH] fix --- main.ipynb | 22 +++++++++++++--------- main.py | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/main.ipynb b/main.ipynb index 42dab91..c22bb83 100644 --- a/main.ipynb +++ b/main.ipynb @@ -4170,16 +4170,20 @@ " user: Dict = Security(get_current_user)\n", "):\n", " data = await invitations_collection.find_one({'_id': ObjectId(invitation_id)})\n", + " match_ = {\n", + " \"$or\": [\n", + " {\"sender._id\": user.get('_id')},\n", + " {\"user._id\": user.get('_id')},\n", + " {\"receiver._id\": user.get('_id')}\n", + " ],\n", + " 'prod': PROD,\n", + " }\n", + " if data.get('competition'):\n", + " match_.update({'competition_id': data.get('competition').get('_id')})\n", + " if data.get('exhibition_id'):\n", + " match_.update({'exhibition_id': data.get('exhibition_id')})\n", " cursor = delivery_collection.aggregate([\n", - " {\"$match\": {\n", - " \"$or\": [\n", - " {\"sender._id\": user.get('_id')},\n", - " {\"user._id\": user.get('_id')},\n", - " {\"receiver._id\": user.get('_id')}\n", - " ],\n", - " 'prod': PROD,\n", - " 'competition_id': data.get('competition').get('_id'),\n", - " }},\n", + " {\"$match\": match_},\n", " {\"$sort\": {\"_id\": -1}},\n", " {\"$group\": {\n", " \"_id\": \"$post_id\",\n", diff --git a/main.py b/main.py index ad433d1..4baa6bc 100644 --- a/main.py +++ b/main.py @@ -3185,16 +3185,20 @@ async def profile_invitation( user: Dict = Security(get_current_user) ): data = await invitations_collection.find_one({'_id': ObjectId(invitation_id)}) + match_ = { + "$or": [ + {"sender._id": user.get('_id')}, + {"user._id": user.get('_id')}, + {"receiver._id": user.get('_id')} + ], + 'prod': PROD, + } + if data.get('competition'): + match_.update({'competition_id': data.get('competition').get('_id')}) + if data.get('exhibition_id'): + match_.update({'exhibition_id': data.get('exhibition_id')}) cursor = delivery_collection.aggregate([ - {"$match": { - "$or": [ - {"sender._id": user.get('_id')}, - {"user._id": user.get('_id')}, - {"receiver._id": user.get('_id')} - ], - 'prod': PROD, - 'competition_id': data.get('competition').get('_id'), - }}, + {"$match": match_}, {"$sort": {"_id": -1}}, {"$group": { "_id": "$post_id",