diff --git a/orm/topic.py b/orm/topic.py index a4b2826f..85925b4a 100644 --- a/orm/topic.py +++ b/orm/topic.py @@ -9,12 +9,11 @@ class TopicFollower(Base): __tablename__ = 'topic_followers' id = None # type: ignore - follower = Column(ForeignKey('author.id'), primary_key=True) - topic = Column(ForeignKey('topic.id'), primary_key=True) - created_at = Column(Integer, nullable=False, default=lambda: int(time.time())) + follower = Column(Integer, ForeignKey('author.id'), primary_key=True) + topic = Column(Integer, ForeignKey('topic.id'), primary_key=True) + created_at = Column(Integer, nullable=False, default=int(time.time())) auto = Column(Boolean, nullable=False, default=False) - class Topic(Base): __tablename__ = 'topic' diff --git a/resolvers/stat.py b/resolvers/stat.py index 5f7bab38..e83ce514 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -191,7 +191,7 @@ def author_follows_topics(author_id: int): subquery_topic_followers = ( select( [ - TopicFollower.topic, + TopicFollower.topic_id, func.count(distinct(TopicFollower.follower)).label('followers_stat'), ] )