stats-fix

This commit is contained in:
Untone 2023-11-30 00:21:22 +03:00
parent f57719d182
commit 537d588853
2 changed files with 10 additions and 12 deletions

View File

@ -403,9 +403,8 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
reaction.stat = {
"rating": rating_stat,
"commented": commented_stat,
"reacted": reacted_stat,
"reacted": reacted_stat
}
reaction.kind = reaction.kind.name
reactions.append(reaction)
# sort if by stat is present

View File

@ -86,16 +86,15 @@ async def get_shout(_, _info, slug=None, shout_id=None):
q = q.filter(Shout.deleted_at.is_(None)).group_by(Shout.id)
try:
[
shout,
viewed_stat,
reacted_stat,
commented_stat,
rating_stat,
] = (
session.execute(q).first() or []
)
if shout:
author_stats = session.execute(q).first()
if author_stats:
[
shout,
viewed_stat,
reacted_stat,
commented_stat,
rating_stat,
] = author_stats
shout.stat = {
"viewed": viewed_stat,
"reacted": reacted_stat,