This commit is contained in:
parent
ebbbe05237
commit
886ca8c0ff
|
@ -138,14 +138,14 @@ async def get_author_follows(_, _info, slug='', user=None, author_id=None):
|
||||||
authors = json.loads(cached) if cached else author_follows_authors(author_id)
|
authors = json.loads(cached) if cached else author_follows_authors(author_id)
|
||||||
if not cached:
|
if not cached:
|
||||||
prepared = [author.dict() for author in authors]
|
prepared = [author.dict() for author in authors]
|
||||||
await redis.execute('SETEX', rkey, json.dumps(prepared), 24*60*60)
|
await redis.execute('SETEX', rkey, 24*60*60, json.dumps(prepared))
|
||||||
|
|
||||||
rkey = f'id:{author_id}:follows-topics'
|
rkey = f'id:{author_id}:follows-topics'
|
||||||
cached = await redis.execute('GET', rkey)
|
cached = await redis.execute('GET', rkey)
|
||||||
topics = json.loads(cached) if cached else author_follows_topics(author_id)
|
topics = json.loads(cached) if cached else author_follows_topics(author_id)
|
||||||
if not cached:
|
if not cached:
|
||||||
prepared = [topic.dict() for topic in topics]
|
prepared = [topic.dict() for topic in topics]
|
||||||
await redis.execute('SETEX', rkey, json.dumps(prepared), 24*60*60)
|
await redis.execute('SETEX', rkey, 24*60*60, json.dumps(prepared))
|
||||||
return {
|
return {
|
||||||
'topics': topics,
|
'topics': topics,
|
||||||
'authors': authors,
|
'authors': authors,
|
||||||
|
@ -174,7 +174,7 @@ async def get_author_follows_topics(_, _info, slug='', user=None, author_id=None
|
||||||
topics = json.loads(cached) if cached else author_follows_topics(author_id)
|
topics = json.loads(cached) if cached else author_follows_topics(author_id)
|
||||||
if not cached:
|
if not cached:
|
||||||
prepared = [topic.dict() for topic in topics]
|
prepared = [topic.dict() for topic in topics]
|
||||||
await redis.execute('SETEX', rkey, json.dumps(prepared), 24*60*60)
|
await redis.execute('SETEX', rkey, 24*60*60, json.dumps(prepared))
|
||||||
return topics
|
return topics
|
||||||
else:
|
else:
|
||||||
raise ValueError('Author not found')
|
raise ValueError('Author not found')
|
||||||
|
@ -197,7 +197,7 @@ async def get_author_follows_authors(_, _info, slug='', user=None, author_id=Non
|
||||||
authors = json.loads(cached) if cached else author_follows_authors(author_id)
|
authors = json.loads(cached) if cached else author_follows_authors(author_id)
|
||||||
if not cached:
|
if not cached:
|
||||||
prepared = [author.dict() for author in authors]
|
prepared = [author.dict() for author in authors]
|
||||||
await redis.execute('SETEX', rkey, json.dumps(prepared), 24*60*60)
|
await redis.execute('SETEX', rkey, 24*60*60, json.dumps(prepared))
|
||||||
return authors
|
return authors
|
||||||
else:
|
else:
|
||||||
raise ValueError('Author not found')
|
raise ValueError('Author not found')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user