This commit is contained in:
vladislav 2026-08-17 10:19:59 -04:00
parent eab4080029
commit b36ba2aaa4
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45

View File

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