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]
|
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")
|
@query.field("topCommented")
|
||||||
async def top_commented(_, _info, offset, limit):
|
async def top_commented(_, _info, offset, limit):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
|
|
|
@ -230,9 +230,10 @@ type Query {
|
||||||
shoutsByCommunities(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
|
shoutsByCommunities(slugs: [String]!, offset: Int!, limit: Int!): [Shout]!
|
||||||
myCandidates(offset: Int!, limit: Int!): [Shout]! # test
|
myCandidates(offset: Int!, limit: Int!): [Shout]! # test
|
||||||
# topReacted(offset: Int!, limit: Int!): [Shout]!
|
# topReacted(offset: Int!, limit: Int!): [Shout]!
|
||||||
topAuthors(offset: Int!, limit: Int!): [Author]!
|
topAuthors(offset: Int!, limit: Int!): [Author]! # by User.rating
|
||||||
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: rename topRatedMonth
|
topPublished(daysago: Int!, offset: Int!, limit: Int!): [Shout]!
|
||||||
topOverall(offset: Int!, limit: Int!): [Shout]! # TODO: rename topRated
|
topMonth(offset: Int!, limit: Int!): [Shout]! # TODO: implement topPublishedAfter(day, offset, limit)
|
||||||
|
topOverall(offset: Int!, limit: Int!): [Shout]!
|
||||||
topCommented(offset: Int!, limit: Int!): [Shout]!
|
topCommented(offset: Int!, limit: Int!): [Shout]!
|
||||||
recentPublished(offset: Int!, limit: Int!): [Shout]! # homepage
|
recentPublished(offset: Int!, limit: Int!): [Shout]! # homepage
|
||||||
recentReacted(offset: Int!, limit: Int!): [Shout]! # TODO: use in design!
|
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()))
|
print("[zine.cache] indexed by %d authors " % len(shouts_by_author.keys()))
|
||||||
ShoutsCache.by_author = shouts_by_author
|
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
|
@staticmethod
|
||||||
async def prepare_by_topic():
|
async def prepare_by_topic():
|
||||||
shouts_by_topic = {}
|
shouts_by_topic = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user