fix-async
This commit is contained in:
parent
88b08882bf
commit
420d6c1f2d
|
@ -120,8 +120,9 @@ async def get_search_results(_, _info, searchtext, offset, limit):
|
|||
@query.field("shoutsByAuthors")
|
||||
async def shouts_by_authors(_, _info, slugs, offset, limit):
|
||||
shouts = []
|
||||
for author in slugs:
|
||||
shouts.extend(await ShoutsCache.get_by_author(author))
|
||||
async with ShoutsCache.lock:
|
||||
for author in slugs:
|
||||
shouts.extend(ShoutsCache.by_author.get(author, []))
|
||||
shouts_prepared = []
|
||||
for s in shouts:
|
||||
if bool(s.publishedAt):
|
||||
|
@ -135,8 +136,9 @@ async def shouts_by_authors(_, _info, slugs, offset, limit):
|
|||
@query.field("shoutsByTopics")
|
||||
async def shouts_by_topics(_, _info, slugs, offset, limit):
|
||||
shouts = []
|
||||
for topic in slugs:
|
||||
shouts.extend(await ShoutsCache.get_by_topic(topic))
|
||||
async with ShoutsCache.lock:
|
||||
for topic in slugs:
|
||||
shouts.extend(ShoutsCache.by_topic.get(topic, []))
|
||||
shouts_prepared = []
|
||||
for s in shouts:
|
||||
if bool(s.publishedAt):
|
||||
|
|
|
@ -244,16 +244,6 @@ class ShoutsCache:
|
|||
print("[zine.cache] indexed by %d authors " % len(shouts_by_author.keys()))
|
||||
ShoutsCache.by_author = shouts_by_author
|
||||
|
||||
@staticmethod
|
||||
async def get_by_author(author):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.by_author.get(author, [])
|
||||
|
||||
@staticmethod
|
||||
async def get_by_topic(topic):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.by_topic.get(topic, [])
|
||||
|
||||
@staticmethod
|
||||
async def get_top_published_before(daysago, offset, limit):
|
||||
shouts_by_rating = []
|
||||
|
|
Loading…
Reference in New Issue
Block a user