This commit is contained in:
vladislav 2026-09-05 23:24:07 -04:00
parent 6e3b6c2d6f
commit 4a26231069
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45
2 changed files with 28 additions and 2 deletions

View File

@ -80,7 +80,6 @@
"import uuid\n",
"import bcrypt\n",
"from typing import List, Any, Dict, Optional, Union\n",
"from datetime import timedelta\n",
"from urllib.parse import urlencode\n",
"from bson import ObjectId\n",
"from PIL import Image\n",
@ -473,6 +472,24 @@
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,
"id": "edb712bd",
"metadata": {},
"outputs": [],
"source": [
"@app.get(\"/cron/08\", response_model=dict)\n",
"async def cron_08():\n",
" async for doc in posts_collection.find({\n",
" '_id': {'$gte': ObjectId.from_datetime(datetime.now() - timedelta(days=1))},\n",
" '$or':[{'vk':[]},{'tg':[]},{'fb':[]},{'inst':[]},{'max':[]}]\n",
" }):\n",
" background_tasks.add_task(publish_social_post, bson_clear(doc))\n",
" return {'ok': True}\n"
],
"display_name": ".venv"
},
{
"cell_type": "code",
"execution_count": null,

11
main.py
View File

@ -19,7 +19,6 @@ from starlette.middleware.gzip import GZipMiddleware
import uuid
import bcrypt
from typing import List, Any, Dict, Optional, Union
from datetime import timedelta
from urllib.parse import urlencode
from bson import ObjectId
from PIL import Image
@ -303,6 +302,16 @@ async def posts_temp(user,request):
request=request, name="profile/posts.html", context={ "user": user, 'cards': data}
)
@app.get("/cron/08", response_model=dict)
async def cron_08():
async for doc in posts_collection.find({
'_id': {'$gte': ObjectId.from_datetime(datetime.now() - timedelta(days=1))},
'$or':[{'vk':[]},{'tg':[]},{'fb':[]},{'inst':[]},{'max':[]}]
}):
background_tasks.add_task(publish_social_post, bson_clear(doc))
return {'ok': True}
@app.get("/cron/day")
async def cron_every_day(token: str = Security(get_token)):
res = await competitions_col.update_many(