From 7a3830653e78a5e1166dd89600ceea1c476e12ae Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 2 Feb 2024 15:59:22 +0300 Subject: [PATCH] fmt --- __init__.py | 0 resolvers/editor.py | 6 +++++- resolvers/follower.py | 1 - resolvers/rater.py | 5 ++--- resolvers/reaction.py | 7 ++++++- services/diff.py | 1 + 6 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/resolvers/editor.py b/resolvers/editor.py index 356d49ad..93f8bc40 100644 --- a/resolvers/editor.py +++ b/resolvers/editor.py @@ -229,7 +229,11 @@ def handle_proposing(session, r, shout): replied_reaction = session.query(Reaction).filter(Reaction.id == r.reply_to).first() if replied_reaction and replied_reaction.kind is ReactionKind.PROPOSE.value and replied_reaction.quote: # patch all the proposals' quotes - proposals = session.query(Reaction).filter(and_(Reaction.shout == r.shout, Reaction.kind == ReactionKind.PROPOSE.value)).all() + proposals = ( + session.query(Reaction) + .filter(and_(Reaction.shout == r.shout, Reaction.kind == ReactionKind.PROPOSE.value)) + .all() + ) for proposal in proposals: if proposal.quote: proposal_diff = get_diff(shout.body, proposal.quote) diff --git a/resolvers/follower.py b/resolvers/follower.py index 7eddddf8..75cf8da3 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -141,7 +141,6 @@ def get_shout_followers(_, _info, slug: str = '', shout_id: int | None = None) - return followers - def reactions_follow(author_id, shout_id, auto=False): try: with local_session() as session: diff --git a/resolvers/rater.py b/resolvers/rater.py index 4e349176..765f33b6 100644 --- a/resolvers/rater.py +++ b/resolvers/rater.py @@ -1,4 +1,3 @@ - from orm.reaction import ReactionKind @@ -8,8 +7,8 @@ RATING_REACTIONS = [ ReactionKind.AGREE.value, ReactionKind.DISLIKE.value, ReactionKind.REJECT.value, - ReactionKind.DISAGREE.value] - + ReactionKind.DISAGREE.value, +] def is_negative(x): diff --git a/resolvers/reaction.py b/resolvers/reaction.py index 3745ac76..5331ccf6 100644 --- a/resolvers/reaction.py +++ b/resolvers/reaction.py @@ -50,6 +50,7 @@ def is_featured_author(session, author_id): > 0 ) + def check_to_feature(session, approver_id, reaction): """set shout to public if publicated approvers amount > 4""" if not reaction.reply_to and is_positive(reaction.kind): @@ -70,7 +71,11 @@ def check_to_unfeature(session, rejecter_id, reaction): """unfeature any shout if 20% of reactions are negative""" if not reaction.reply_to and is_negative(reaction.kind): if is_featured_author(session, rejecter_id): - reactions = session.query(Reaction).where(and_(Reaction.shout == reaction.shout, Reaction.kind.in_(RATING_REACTIONS))).all() + reactions = ( + session.query(Reaction) + .where(and_(Reaction.shout == reaction.shout, Reaction.kind.in_(RATING_REACTIONS))) + .all() + ) rejects = 0 for r in reactions: approver = session.query(Author).filter(Author.id == r.created_by).first() diff --git a/services/diff.py b/services/diff.py index 44ac353b..75a99fac 100644 --- a/services/diff.py +++ b/services/diff.py @@ -16,6 +16,7 @@ def get_diff(original, modified): diff = list(ndiff(original.split(), modified.split())) return diff + def apply_diff(original, diff): """ Apply the difference to the original string.