topic-stat-query-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m19s

This commit is contained in:
Untone 2024-02-23 21:22:55 +03:00
parent a05072fd71
commit f04e20426f
2 changed files with 4 additions and 5 deletions

View File

@ -9,12 +9,11 @@ class TopicFollower(Base):
__tablename__ = 'topic_followers' __tablename__ = 'topic_followers'
id = None # type: ignore id = None # type: ignore
follower = Column(ForeignKey('author.id'), primary_key=True) follower = Column(Integer, ForeignKey('author.id'), primary_key=True)
topic = Column(ForeignKey('topic.id'), primary_key=True) topic = Column(Integer, ForeignKey('topic.id'), primary_key=True)
created_at = Column(Integer, nullable=False, default=lambda: int(time.time())) created_at = Column(Integer, nullable=False, default=int(time.time()))
auto = Column(Boolean, nullable=False, default=False) auto = Column(Boolean, nullable=False, default=False)
class Topic(Base): class Topic(Base):
__tablename__ = 'topic' __tablename__ = 'topic'

View File

@ -191,7 +191,7 @@ def author_follows_topics(author_id: int):
subquery_topic_followers = ( subquery_topic_followers = (
select( select(
[ [
TopicFollower.topic, TopicFollower.topic_id,
func.count(distinct(TopicFollower.follower)).label('followers_stat'), func.count(distinct(TopicFollower.follower)).label('followers_stat'),
] ]
) )