This commit is contained in:
parent
e529ecbe41
commit
4fe15d1440
|
@ -182,17 +182,17 @@ async def get_author_follows(_, _info, slug='', user=None, author_id=0):
|
|||
rkey = f'author:{author_id}:follows-authors'
|
||||
logger.debug(f'getting {author_id} follows authors')
|
||||
cached = await redis.execute('GET', rkey)
|
||||
authors = []
|
||||
if not cached:
|
||||
authors = author_follows_authors(author_id)
|
||||
prepared = [author.dict() for author in authors]
|
||||
await redis.execute(
|
||||
'SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder)
|
||||
)
|
||||
await redis.execute('SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder))
|
||||
elif isinstance(cached, str):
|
||||
authors = json.loads(cached)
|
||||
|
||||
rkey = f'author:{author_id}:follows-topics'
|
||||
cached = await redis.execute('GET', rkey)
|
||||
topics = []
|
||||
if cached and isinstance(cached, str):
|
||||
topics = json.loads(cached)
|
||||
if not cached:
|
||||
|
|
|
@ -16,10 +16,17 @@ def add_topic_stat_columns(q):
|
|||
aliased_shout = aliased(Shout)
|
||||
|
||||
q = (
|
||||
q.outerjoin(aliased_shout_topic, and_(aliased_shout_topic.topic == Topic.id, aliased_shout.published_at.is_not(None)))
|
||||
q.outerjoin(aliased_shout_topic, aliased_shout_topic.topic == Topic.id)
|
||||
.add_columns(
|
||||
func.count(distinct(aliased_shout_topic.shout)).label('shouts_stat')
|
||||
)
|
||||
.outerjoin(
|
||||
aliased_shout_author,
|
||||
and_(
|
||||
aliased_shout_topic.shout == aliased_shout_author.shout,
|
||||
aliased_shout.published_at.is_not(None),
|
||||
)
|
||||
)
|
||||
.outerjoin(
|
||||
aliased_shout_author,
|
||||
aliased_shout_topic.shout == aliased_shout_author.shout,
|
||||
|
|
Loading…
Reference in New Issue
Block a user