typo-fix
All checks were successful
Deploy on push / deploy (push) Successful in 24s

This commit is contained in:
Untone 2024-05-05 00:00:58 +03:00
parent dc791d4e7a
commit c9205a698f
2 changed files with 17 additions and 15 deletions

View File

@ -150,7 +150,7 @@ async def load_authors_by(_, _info, by, limit, offset):
q = q.limit(limit).offset(offset) q = q.limit(limit).offset(offset)
authors_nostat = local_session().session(q) authors_nostat = local_session().execute(q)
authors = [] authors = []
if authors_nostat: if authors_nostat:
for [a] in authors_nostat: for [a] in authors_nostat:

View File

@ -175,26 +175,28 @@ def prepare_new_rating(reaction: dict, shout_id: int, session, author_id: int):
Reaction.shout == shout_id, Reaction.shout == shout_id,
Reaction.created_by == author_id, Reaction.created_by == author_id,
Reaction.kind.in_(RATING_REACTIONS), Reaction.kind.in_(RATING_REACTIONS),
Reaction.deleted_at.is_not(None),
) )
) )
reply_to = reaction.get("reply_to") reply_to = reaction.get("reply_to")
if reply_to and isinstance(reply_to, int): if reply_to and isinstance(reply_to, int):
q = q.filter(Reaction.reply_to == reply_to) q = q.filter(Reaction.reply_to == reply_to)
rating_reactions = session.execute(q).all() rating_reactions = session.execute(q).all()
same_rating = filter( if rating_reactions:
lambda r: r.created_by == author_id and r.kind == kind, same_rating = filter(
rating_reactions, lambda r: r.created_by == author_id and r.kind == kind,
) rating_reactions,
opposite_rating = filter( )
lambda r: r.created_by == author_id and r.kind == opposite_kind, opposite_rating = filter(
rating_reactions, lambda r: r.created_by == author_id and r.kind == opposite_kind,
) rating_reactions,
if same_rating: )
return {"error": "You can't rate the same thing twice"} if same_rating:
elif opposite_rating: return {"error": "You can't rate the same thing twice"}
return {"error": "Remove opposite vote first"} elif opposite_rating:
elif filter(lambda r: r.created_by == author_id, rating_reactions): return {"error": "Remove opposite vote first"}
return {"error": "You can't rate your own thing"} elif filter(lambda r: r.created_by == author_id, rating_reactions):
return {"error": "You can't rate your own thing"}
return return