create-shout-fix2

This commit is contained in:
Untone 2025-01-21 18:28:03 +03:00
parent 1ed185a701
commit 8432a00691
2 changed files with 16 additions and 16 deletions

View File

@ -113,13 +113,13 @@ async def create_shout(_, info, inp):
logger.info(f"Creating shout with slug: {slug}")
# Создаем объект Shout напрямую, без промежуточного словаря
new_shout = Shout({
**inp,
"slug": slug,
"created_by": author_id,
"created_at": current_time
})
# Правильно:
new_shout = Shout(
**inp, # распаковываем входные данные
slug=slug, # явно указываем именованные аргументы
created_by=author_id,
created_at=current_time,
)
# Check for duplicate slug
logger.debug(f"Checking for existing slug: {slug}")
@ -195,7 +195,7 @@ async def create_shout(_, info, inp):
try:
author = session.query(Author).filter(Author.id == author_id).first()
if author and author.stat:
author.stat["shouts"] = (author.stat.get("shouts", 0) + 1)
author.stat["shouts"] = author.stat.get("shouts", 0) + 1
session.add(author)
session.commit()
await cache_author(author.dict())