undublicate

This commit is contained in:
tonyrewin 2022-10-04 17:03:13 +03:00
parent 4bc5d90168
commit 5da27fffa5
2 changed files with 12 additions and 11 deletions

View File

@ -43,7 +43,7 @@ async def topics_by_community(_, info, community):
@query.field("topicsByAuthor") @query.field("topicsByAuthor")
async def topics_by_author(_, _info, author): async def topics_by_author(_, _info, author):
shouts = ShoutsCache.by_author.get(author) shouts = ShoutsCache.by_author.get(author, [])
author_topics = set() author_topics = set()
for s in shouts: for s in shouts:
for tpc in s.topics: for tpc in s.topics:

View File

@ -120,8 +120,8 @@ async def shouts_by_authors(_, _info, slugs, offset, limit):
if bool(s.publishedAt): if bool(s.publishedAt):
for a in s.authors: for a in s.authors:
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug) a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
if s not in shouts_prepared:
shouts_prepared.append(s) shouts_prepared.append(s)
shouts_prepared = list(set(shouts_prepared))
shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True) shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True)
return shouts_prepared[offset : offset + limit] return shouts_prepared[offset : offset + limit]
@ -137,6 +137,7 @@ async def shouts_by_topics(_, _info, slugs, offset, limit):
if bool(s.publishedAt): if bool(s.publishedAt):
for a in s.authors: for a in s.authors:
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug) a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
if s not in shouts_prepared:
shouts_prepared.append(s) shouts_prepared.append(s)
shouts_prepared = list(set(shouts_prepared)) shouts_prepared = list(set(shouts_prepared))
shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True) shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True)