get-shout-fix
Some checks failed
Deploy on push / deploy (push) Failing after 10s

This commit is contained in:
Untone 2024-10-31 18:37:00 +03:00
parent 0c83b9c401
commit 1114c7766d

View File

@ -392,24 +392,20 @@ async def get_shout(_, _info, slug="", shout_id=0):
topics_json, topics_json,
main_topic_slug, main_topic_slug,
] = results ] = results
viewed_stat = ViewedStorage.get_shout(shout.id)
shout.stat = { shout_dict = shout.dict()
"viewed": ViewedStorage.get_shout(shout.id), shout_dict["stat"] = {
"commented": commented_stat, "viewed": viewed_stat or 0,
"rating": rating_stat, "commented": commented_stat or 0,
"last_reacted_at": last_reaction_at, "rating": rating_stat or 0,
"last_reacted_at": last_reaction_at or 0,
} }
# Преобразование строк в объекты Author без их создания shout_dict["authors"] = authors_json or []
shout.authors = [Author(**author) for author in authors_json] if authors_json else [] shout_dict["topics"] = topics_json or []
shout_dict["main_topic"] = main_topic_slug
# Преобразование строк в объекты Topic без их создания return shout_dict
shout.topics = [Topic(**topic) for topic in topics_json] if topics_json else []
# Добавляем основной топик, если он существует
shout.main_topic = main_topic_slug
return shout
except Exception as _exc: except Exception as _exc:
import traceback import traceback