From 5f8ec549df12bbd2d68528d476b53fe3887a255d Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 27 Nov 2023 21:03:59 +0300 Subject: [PATCH] emptybody-fix --- CHANGELOG.txt | 2 +- orm/reaction.py | 2 +- resolvers/author.py | 2 +- resolvers/community.py | 2 +- resolvers/reaction.py | 4 ++-- resolvers/reader.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8cfb51f4..4d92c419 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -25,7 +25,7 @@ - services: views are not stored in core db anymore - schema: snake case in model fields names - schema: no DateTime scalar -- resolvers: get_my_feed comments filter reactions body.is_not("") +- resolvers: get_my_feed comments filter reactions body.is_not('') - resolvers: get_my_feed query fix - resolvers: LoadReactionsBy.days -> LoadReactionsBy.time_ago - resolvers: LoadShoutsBy.days -> LoadShoutsBy.time_ago diff --git a/orm/reaction.py b/orm/reaction.py index 10733052..4581eb40 100644 --- a/orm/reaction.py +++ b/orm/reaction.py @@ -29,7 +29,7 @@ class ReactionKind(Enumeration): class Reaction(Base): __tablename__ = "reaction" - body = Column(String, nullable=True, comment="Reaction Body") + body = Column(String, default='', comment="Reaction Body") created_at = Column(Integer, nullable=False, default=lambda: int(time.time())) created_by = Column(ForeignKey("author.id"), nullable=False, index=True) updated_at = Column(Integer, nullable=True, comment="Updated at") diff --git a/resolvers/author.py b/resolvers/author.py index 278a8d33..22b62bf3 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -39,7 +39,7 @@ def add_author_stat_columns(q): # ) q = q.add_columns(literal(0).label("commented_stat")) - # q = q.outerjoin(Reaction, and_(Reaction.created_by == Author.id, Reaction.body.is_not(None))).add_columns( + # q = q.outerjoin(Reaction, and_(Reaction.created_by == Author.id, Reaction.body.is_not(''))).add_columns( # func.count(distinct(Reaction.id)).label('commented_stat') # ) diff --git a/resolvers/community.py b/resolvers/community.py index 30d191d0..8e34015f 100644 --- a/resolvers/community.py +++ b/resolvers/community.py @@ -26,7 +26,7 @@ def add_community_stat_columns(q): # ) q = q.add_columns(literal(0).label("commented_stat")) - # q = q.outerjoin(Reaction, and_(Reaction.created_by == Author.id, Reaction.body.is_not(None))).add_columns( + # q = q.outerjoin(Reaction, and_(Reaction.created_by == Author.id, Reaction.body.is_not(''))).add_columns( # func.count(distinct(Reaction.id)).label('commented_stat') # ) diff --git a/resolvers/reaction.py b/resolvers/reaction.py index c9908f39..7b5228cc 100644 --- a/resolvers/reaction.py +++ b/resolvers/reaction.py @@ -17,7 +17,7 @@ def add_reaction_stat_columns(q): q = q.outerjoin(aliased_reaction, Reaction.id == aliased_reaction.reply_to).add_columns( func.sum(aliased_reaction.id).label("reacted_stat"), - func.sum(case((aliased_reaction.body.is_not(None), 1), else_=0)).label("commented_stat"), + func.sum(case((aliased_reaction.body.is_not(''), 1), else_=0)).label("commented_stat"), func.sum( case( (aliased_reaction.kind == ReactionKind.AGREE, 1), @@ -91,7 +91,7 @@ def is_published_author(session, author_id): return ( session.query(Shout) .where(Shout.authors.contains(author_id)) - .filter(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None))) + .filter(and_(Shout.published_at.is_not(''), Shout.deleted_at.is_(None))) .count() > 0 ) diff --git a/resolvers/reader.py b/resolvers/reader.py index c365ca86..0d4355cc 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -21,7 +21,7 @@ def add_stat_columns(q): func.sum( case( # do not count comments' reactions - (aliased_reaction.body.is_not(""), 0), + (aliased_reaction.body.is_not(''), 0), (aliased_reaction.kind == ReactionKind.AGREE, 1), (aliased_reaction.kind == ReactionKind.DISAGREE, -1), (aliased_reaction.kind == ReactionKind.PROOF, 1),