cache-when-created
All checks were successful
Deploy on push / deploy (push) Successful in 28s

This commit is contained in:
2024-05-18 13:57:30 +03:00
parent bc01dfb125
commit 7d97f40826
2 changed files with 22 additions and 4 deletions

View File

@@ -6,8 +6,12 @@ from starlette.exceptions import HTTPException
from starlette.requests import Request
from starlette.responses import JSONResponse
from sqlalchemy import select
from orm.author import Author
from services.db import local_session
from services.cache import cache_author
from resolvers.stat import get_with_stat
class WebhookEndpoint(HTTPEndpoint):
@@ -56,6 +60,11 @@ class WebhookEndpoint(HTTPEndpoint):
author = Author(user=user_id, slug=slug, name=name, pic=pic)
session.add(author)
session.commit()
[author_with_stat] = get_with_stat(
select(Author).filter(Author.id == author.id)
)
if author_with_stat:
await cache_author(author_with_stat)
return JSONResponse({"status": "success"})
except HTTPException as e: