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 = { reaction.stat = {
"rating": rating_stat, "rating": rating_stat,
"commented": commented_stat, "commented": commented_stat,
"reacted": reacted_stat, "reacted": reacted_stat
} }
reaction.kind = reaction.kind.name
reactions.append(reaction) reactions.append(reaction)
# sort if by stat is present # 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) q = q.filter(Shout.deleted_at.is_(None)).group_by(Shout.id)
try: try:
[ author_stats = session.execute(q).first()
shout, if author_stats:
viewed_stat, [
reacted_stat, shout,
commented_stat, viewed_stat,
rating_stat, reacted_stat,
] = ( commented_stat,
session.execute(q).first() or [] rating_stat,
) ] = author_stats
if shout:
shout.stat = { shout.stat = {
"viewed": viewed_stat, "viewed": viewed_stat,
"reacted": reacted_stat, "reacted": reacted_stat,