page from 1
This commit is contained in:
parent
bce71a6be8
commit
78986f6001
|
@ -193,22 +193,22 @@ class ShoutSubscriptions:
|
||||||
@query.field("topViewed")
|
@query.field("topViewed")
|
||||||
async def top_viewed(_, info, page, size):
|
async def top_viewed(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.top_viewed[page * size : (page + 1) * size]
|
return ShoutsCache.top_viewed[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@query.field("topMonth")
|
@query.field("topMonth")
|
||||||
async def top_month(_, info, page, size):
|
async def top_month(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.top_month[page * size : (page + 1) * size]
|
return ShoutsCache.top_month[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@query.field("topOverall")
|
@query.field("topOverall")
|
||||||
async def top_overall(_, info, page, size):
|
async def top_overall(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.top_overall[page * size : (page + 1) * size]
|
return ShoutsCache.top_overall[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@query.field("recents")
|
@query.field("recents")
|
||||||
async def recent_shouts(_, info, page, size):
|
async def recent_shouts(_, info, page, size):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.recent_shouts[page * size : (page + 1) * size]
|
return ShoutsCache.recent_shouts[(page - 1) * size : page * size]
|
||||||
|
|
||||||
@mutation.field("createShout")
|
@mutation.field("createShout")
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -353,6 +353,7 @@ async def get_shout_comments(_, info, slug):
|
||||||
|
|
||||||
@query.field("shoutsByTopic")
|
@query.field("shoutsByTopic")
|
||||||
async def shouts_by_topic(_, info, topic, page, size):
|
async def shouts_by_topic(_, info, topic, page, size):
|
||||||
|
page = page - 1
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shouts = session.query(Shout).\
|
shouts = session.query(Shout).\
|
||||||
join(ShoutTopic).\
|
join(ShoutTopic).\
|
||||||
|
@ -364,6 +365,7 @@ async def shouts_by_topic(_, info, topic, page, size):
|
||||||
|
|
||||||
@query.field("shoutsByAuthor")
|
@query.field("shoutsByAuthor")
|
||||||
async def shouts_by_author(_, info, author, page, size):
|
async def shouts_by_author(_, info, author, page, size):
|
||||||
|
page = page - 1
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
user = session.query(User).\
|
user = session.query(User).\
|
||||||
filter(User.slug == author).first()
|
filter(User.slug == author).first()
|
||||||
|
@ -381,8 +383,8 @@ async def shouts_by_author(_, info, author, page, size):
|
||||||
|
|
||||||
@query.field("shoutsByCommunity")
|
@query.field("shoutsByCommunity")
|
||||||
async def shouts_by_community(_, info, community, page, size):
|
async def shouts_by_community(_, info, community, page, size):
|
||||||
|
page = page - 1
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
|
||||||
#TODO fix postgres high load
|
#TODO fix postgres high load
|
||||||
shouts = session.query(Shout).distinct().\
|
shouts = session.query(Shout).distinct().\
|
||||||
join(ShoutTopic).\
|
join(ShoutTopic).\
|
||||||
|
|
Loading…
Reference in New Issue
Block a user