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")
|
@query.field("shoutsByAuthors")
|
||||||
async def shouts_by_authors(_, _info, slugs, offset, limit):
|
async def shouts_by_authors(_, _info, slugs, offset, limit):
|
||||||
shouts = []
|
shouts = []
|
||||||
for author in slugs:
|
async with ShoutsCache.lock:
|
||||||
shouts.extend(await ShoutsCache.get_by_author(author))
|
for author in slugs:
|
||||||
|
shouts.extend(ShoutsCache.by_author.get(author, []))
|
||||||
shouts_prepared = []
|
shouts_prepared = []
|
||||||
for s in shouts:
|
for s in shouts:
|
||||||
if bool(s.publishedAt):
|
if bool(s.publishedAt):
|
||||||
|
@ -135,8 +136,9 @@ async def shouts_by_authors(_, _info, slugs, offset, limit):
|
||||||
@query.field("shoutsByTopics")
|
@query.field("shoutsByTopics")
|
||||||
async def shouts_by_topics(_, _info, slugs, offset, limit):
|
async def shouts_by_topics(_, _info, slugs, offset, limit):
|
||||||
shouts = []
|
shouts = []
|
||||||
for topic in slugs:
|
async with ShoutsCache.lock:
|
||||||
shouts.extend(await ShoutsCache.get_by_topic(topic))
|
for topic in slugs:
|
||||||
|
shouts.extend(ShoutsCache.by_topic.get(topic, []))
|
||||||
shouts_prepared = []
|
shouts_prepared = []
|
||||||
for s in shouts:
|
for s in shouts:
|
||||||
if bool(s.publishedAt):
|
if bool(s.publishedAt):
|
||||||
|
|
|
@ -244,16 +244,6 @@ 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_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
|
@staticmethod
|
||||||
async def get_top_published_before(daysago, offset, limit):
|
async def get_top_published_before(daysago, offset, limit):
|
||||||
shouts_by_rating = []
|
shouts_by_rating = []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user