This commit is contained in:
parent
08b69e5d0a
commit
7a3830653e
|
@ -229,7 +229,11 @@ def handle_proposing(session, r, shout):
|
||||||
replied_reaction = session.query(Reaction).filter(Reaction.id == r.reply_to).first()
|
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:
|
if replied_reaction and replied_reaction.kind is ReactionKind.PROPOSE.value and replied_reaction.quote:
|
||||||
# patch all the proposals' quotes
|
# 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:
|
for proposal in proposals:
|
||||||
if proposal.quote:
|
if proposal.quote:
|
||||||
proposal_diff = get_diff(shout.body, proposal.quote)
|
proposal_diff = get_diff(shout.body, proposal.quote)
|
||||||
|
|
|
@ -141,7 +141,6 @@ def get_shout_followers(_, _info, slug: str = '', shout_id: int | None = None) -
|
||||||
return followers
|
return followers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reactions_follow(author_id, shout_id, auto=False):
|
def reactions_follow(author_id, shout_id, auto=False):
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
from orm.reaction import ReactionKind
|
from orm.reaction import ReactionKind
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +7,8 @@ RATING_REACTIONS = [
|
||||||
ReactionKind.AGREE.value,
|
ReactionKind.AGREE.value,
|
||||||
ReactionKind.DISLIKE.value,
|
ReactionKind.DISLIKE.value,
|
||||||
ReactionKind.REJECT.value,
|
ReactionKind.REJECT.value,
|
||||||
ReactionKind.DISAGREE.value]
|
ReactionKind.DISAGREE.value,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def is_negative(x):
|
def is_negative(x):
|
||||||
|
|
|
@ -50,6 +50,7 @@ def is_featured_author(session, author_id):
|
||||||
> 0
|
> 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_to_feature(session, approver_id, reaction):
|
def check_to_feature(session, approver_id, reaction):
|
||||||
"""set shout to public if publicated approvers amount > 4"""
|
"""set shout to public if publicated approvers amount > 4"""
|
||||||
if not reaction.reply_to and is_positive(reaction.kind):
|
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"""
|
"""unfeature any shout if 20% of reactions are negative"""
|
||||||
if not reaction.reply_to and is_negative(reaction.kind):
|
if not reaction.reply_to and is_negative(reaction.kind):
|
||||||
if is_featured_author(session, rejecter_id):
|
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
|
rejects = 0
|
||||||
for r in reactions:
|
for r in reactions:
|
||||||
approver = session.query(Author).filter(Author.id == r.created_by).first()
|
approver = session.query(Author).filter(Author.id == r.created_by).first()
|
||||||
|
|
|
@ -16,6 +16,7 @@ def get_diff(original, modified):
|
||||||
diff = list(ndiff(original.split(), modified.split()))
|
diff = list(ndiff(original.split(), modified.split()))
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
|
|
||||||
def apply_diff(original, diff):
|
def apply_diff(original, diff):
|
||||||
"""
|
"""
|
||||||
Apply the difference to the original string.
|
Apply the difference to the original string.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user