feat
This commit is contained in:
parent
6e3b6c2d6f
commit
4a26231069
19
main.ipynb
19
main.ipynb
@ -80,7 +80,6 @@
|
|||||||
"import uuid\n",
|
"import uuid\n",
|
||||||
"import bcrypt\n",
|
"import bcrypt\n",
|
||||||
"from typing import List, Any, Dict, Optional, Union\n",
|
"from typing import List, Any, Dict, Optional, Union\n",
|
||||||
"from datetime import timedelta\n",
|
|
||||||
"from urllib.parse import urlencode\n",
|
"from urllib.parse import urlencode\n",
|
||||||
"from bson import ObjectId\n",
|
"from bson import ObjectId\n",
|
||||||
"from PIL import Image\n",
|
"from PIL import Image\n",
|
||||||
@ -473,6 +472,24 @@
|
|||||||
],
|
],
|
||||||
"display_name": ".venv"
|
"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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
11
main.py
11
main.py
@ -19,7 +19,6 @@ from starlette.middleware.gzip import GZipMiddleware
|
|||||||
import uuid
|
import uuid
|
||||||
import bcrypt
|
import bcrypt
|
||||||
from typing import List, Any, Dict, Optional, Union
|
from typing import List, Any, Dict, Optional, Union
|
||||||
from datetime import timedelta
|
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
from PIL import Image
|
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}
|
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")
|
@app.get("/cron/day")
|
||||||
async def cron_every_day(token: str = Security(get_token)):
|
async def cron_every_day(token: str = Security(get_token)):
|
||||||
res = await competitions_col.update_many(
|
res = await competitions_col.update_many(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user