join-maintopic-unrated
All checks were successful
Deploy on push / deploy (push) Successful in 5s

This commit is contained in:
Untone 2024-11-03 11:32:05 +03:00
parent 08fb1d3510
commit 34511a8edf
2 changed files with 15 additions and 6 deletions

View File

@ -80,16 +80,21 @@ class User(Base):
userpic = Column(String, nullable=True, comment="Userpic")
name = Column(String, nullable=True, comment="Display name")
slug = Column(String, unique=True, comment="User's slug")
muted = Column(Boolean, default=False)
emailConfirmed = Column(Boolean, default=False)
createdAt = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Created at")
lastSeen = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Was online at")
deletedAt = Column(DateTime(timezone=True), nullable=True, comment="Deleted at")
links = Column(JSON, nullable=True, comment="Links")
oauth = Column(String, nullable=True)
oid = Column(String, nullable=True)
muted = Column(Boolean, default=False)
confirmed = Column(Boolean, default=False)
created_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Created at")
updated_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Updated at")
last_seen = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), comment="Was online at")
deleted_at = Column(DateTime(timezone=True), nullable=True, comment="Deleted at")
ratings = relationship(UserRating, foreign_keys=UserRating.user)
roles = relationship(lambda: Role, secondary=UserRole.__tablename__)
oid = Column(String, nullable=True)
def get_permission(self):
scope = {}

View File

@ -416,8 +416,12 @@ async def load_shouts_unrated(_, info, options):
.scalar_subquery()
)
# add topic inside output data in main_topic field
aliased_topic = aliased(Topic)
q = (
select(Shout)
.join(aliased_topic, aliased_topic.id == Shout.main_topic.id)
.where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None), ~Shout.id.in_(rated_shouts)))
# .order_by(desc(Shout.published_at))
.order_by(func.random())