shoutscache, format

This commit is contained in:
2022-09-07 19:19:06 +03:00
parent 742042398c
commit 365c2f25e7
9 changed files with 129 additions and 33 deletions

View File

@@ -18,42 +18,42 @@ from sqlalchemy.orm import selectinload
@query.field("topViewed")
async def top_viewed(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.top_viewed[((page - 1) * size) : (page * size)]
return ShoutsCache.get_top_viewed[((page - 1) * size) : (page * size)]
@query.field("topMonth")
async def top_month(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.top_month[((page - 1) * size) : (page * size)]
return ShoutsCache.get_top_month[((page - 1) * size) : (page * size)]
@query.field("topOverall")
async def top_overall(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.top_overall[((page - 1) * size) : (page * size)]
return ShoutsCache.get_top_overall[((page - 1) * size) : (page * size)]
@query.field("recentPublished")
async def recent_published(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.recent_published[((page - 1) * size) : (page * size)]
return ShoutsCache.get_recent_published[((page - 1) * size) : (page * size)]
@query.field("recentAll")
async def recent_all(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.recent_all[((page - 1) * size) : (page * size)]
return ShoutsCache.get_recent_all[((page - 1) * size) : (page * size)]
@query.field("recentReacted")
async def recent_reacted(_, info, page, size):
async with ShoutsCache.lock:
return ShoutsCache.recent_reacted[((page - 1) * size) : (page * size)]
return ShoutsCache.get_recent_reacted[((page - 1) * size) : (page * size)]
@mutation.field("viewShout")
async def view_shout(_, info, slug):
await ViewedStorage.inc_shout(slug)
await ViewedStorage.increment(slug)
return {"error": ""}