fix recentCommented
This commit is contained in:
parent
847240e20f
commit
873d05e000
|
@ -98,15 +98,15 @@ class ShoutsCache:
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
ShoutsCache.recent_shouts = shouts
|
ShoutsCache.recent_shouts = shouts
|
||||||
|
|
||||||
# TODO: DEBUG ME
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def prepare_recent_commented():
|
async def prepare_recent_commented():
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
stmt = select(Shout).\
|
stmt = select(Shout, func.max(Comment.createdAt).label("commentCreatedAt")).\
|
||||||
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
join(Comment).\
|
join(Comment).\
|
||||||
where(and_(Shout.publishedAt != None, Comment.publishedAt == User.id)).\
|
where(and_(Shout.publishedAt != None, Comment.deletedAt == None)).\
|
||||||
order_by(desc("publishedAt")).\
|
group_by(Shout.slug).\
|
||||||
|
order_by(desc("commentCreatedAt")).\
|
||||||
limit(ShoutsCache.limit)
|
limit(ShoutsCache.limit)
|
||||||
shouts = []
|
shouts = []
|
||||||
for row in session.execute(stmt):
|
for row in session.execute(stmt):
|
||||||
|
@ -114,7 +114,7 @@ class ShoutsCache:
|
||||||
shout.ratings = await ShoutRatingStorage.get_ratings(shout.slug)
|
shout.ratings = await ShoutRatingStorage.get_ratings(shout.slug)
|
||||||
shouts.append(shout)
|
shouts.append(shout)
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
ShoutsCache.recent_shouts = shouts
|
ShoutsCache.recent_commented = shouts
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user