load topics and authors
This commit is contained in:
parent
5cca55d66c
commit
7f8908a84b
|
@ -78,6 +78,7 @@ class ShoutsCache:
|
||||||
async def prepare_recent_shouts():
|
async def prepare_recent_shouts():
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
stmt = select(Shout).\
|
stmt = select(Shout).\
|
||||||
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
order_by(desc("createdAt")).\
|
order_by(desc("createdAt")).\
|
||||||
limit(ShoutsCache.limit)
|
limit(ShoutsCache.limit)
|
||||||
shouts = []
|
shouts = []
|
||||||
|
@ -94,6 +95,7 @@ class ShoutsCache:
|
||||||
async def prepare_top_overall():
|
async def prepare_top_overall():
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
stmt = select(Shout, func.sum(ShoutRating.value).label("rating")).\
|
stmt = select(Shout, func.sum(ShoutRating.value).label("rating")).\
|
||||||
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
join(ShoutRating).\
|
join(ShoutRating).\
|
||||||
group_by(Shout.id).\
|
group_by(Shout.id).\
|
||||||
order_by(desc("rating")).\
|
order_by(desc("rating")).\
|
||||||
|
@ -112,6 +114,7 @@ class ShoutsCache:
|
||||||
month_ago = datetime.now() - timedelta(days = 30)
|
month_ago = datetime.now() - timedelta(days = 30)
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
stmt = select(Shout, func.sum(ShoutRating.value).label("rating")).\
|
stmt = select(Shout, func.sum(ShoutRating.value).label("rating")).\
|
||||||
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
join(ShoutRating).\
|
join(ShoutRating).\
|
||||||
where(Shout.createdAt > month_ago).\
|
where(Shout.createdAt > month_ago).\
|
||||||
group_by(Shout.id).\
|
group_by(Shout.id).\
|
||||||
|
@ -131,6 +134,7 @@ class ShoutsCache:
|
||||||
month_ago = datetime.now() - timedelta(days = 30)
|
month_ago = datetime.now() - timedelta(days = 30)
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
stmt = select(Shout, func.sum(ShoutViewByDay.value).label("views")).\
|
stmt = select(Shout, func.sum(ShoutViewByDay.value).label("views")).\
|
||||||
|
options(selectinload(Shout.authors), selectinload(Shout.topics)).\
|
||||||
join(ShoutViewByDay).\
|
join(ShoutViewByDay).\
|
||||||
where(ShoutViewByDay.day > month_ago).\
|
where(ShoutViewByDay.day > month_ago).\
|
||||||
group_by(Shout.id).\
|
group_by(Shout.id).\
|
||||||
|
|
Loading…
Reference in New Issue
Block a user