This commit is contained in:
vladislav 2026-08-17 10:21:05 -04:00
parent b36ba2aaa4
commit 2fa5c0c39f
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45

21
main.py
View File

@ -3185,7 +3185,26 @@ async def profile_invitation(
user: Dict = Security(get_current_user)
):
data = await invitations_collection.find_one({'_id': ObjectId(invitation_id)})
posts = await delivery_collection.find({'competition_id': data.get('competition').get('_id')}).to_list()
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'),
}},
{"$sort": {"_id": -1}},
{"$group": {
"_id": "$post_id",
"doc": {"$first": "$$ROOT"}
}},
{"$replaceRoot": {"newRoot": "$doc"}},
{"$sort": {"_id": -1}},
])
posts = [doc async for doc in cursor]
return templates.TemplateResponse(
request=request, name="profile/invitation.html", context={ "user": user, "doc": data, "data": posts}
)