topPublished
This commit is contained in:
parent
e41856dbc3
commit
c292d7da55
|
@ -29,6 +29,12 @@ async def top_month(_, _info, offset, limit):
|
|||
return ShoutsCache.top_month[offset : offset + limit]
|
||||
|
||||
|
||||
@query.field("topPublished")
|
||||
async def top_published(_, _info, daysago, offset, limit):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_top_published_before(daysago, offset, limit)
|
||||
|
||||
|
||||
@query.field("topCommented")
|
||||
async def top_commented(_, _info, offset, limit):
|
||||
async with ShoutsCache.lock:
|
||||
|
|
|
@ -230,9 +230,10 @@ type Query {
|
|||
shoutsByCommunities(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
|
||||
myCandidates(offset: Int!, limit: Int!): [Shout]! # test
|
||||
# topReacted(offset: Int!, limit: Int!): [Shout]!
|
||||
topAuthors(offset: Int!, limit: Int!): [Author]!
|
||||
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: rename topRatedMonth
|
||||
topOverall(offset: Int!, limit: Int!): [Shout]! # TODO: rename topRated
|
||||
topAuthors(offset: Int!, limit: Int!): [Author]! # by User.rating
|
||||
topPublished(daysago: Int!, offset: Int!, limit: Int!): [Shout]!
|
||||
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: implement topPublishedAfter(day, offset, limit)
|
||||
topOverall(offset: Int!, limit: Int!): [Shout]!
|
||||
topCommented(offset: Int!, limit: Int!): [Shout]!
|
||||
recentPublished(offset: Int!, limit: Int!): [Shout]! # homepage
|
||||
recentReacted(offset: Int!, limit: Int!): [Shout]! # TODO: use in design!
|
||||
|
|
|
@ -248,6 +248,15 @@ class ShoutsCache:
|
|||
print("[zine.cache] indexed by %d authors " % len(shouts_by_author.keys()))
|
||||
ShoutsCache.by_author = shouts_by_author
|
||||
|
||||
@staticmethod
|
||||
async def get_top_published_before(daysago, offset, limit):
|
||||
shouts_by_rating = []
|
||||
before = datetime.now() - timedelta(days=daysago)
|
||||
for s in ShoutsCache.recent_published:
|
||||
if s.publishedAt >= before:
|
||||
shouts_by_rating.append(s)
|
||||
return shouts_by_rating
|
||||
|
||||
@staticmethod
|
||||
async def prepare_by_topic():
|
||||
shouts_by_topic = {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user