diff --git a/migration/tables/comments.py b/migration/tables/comments.py index b2dda926..26e48f57 100644 --- a/migration/tables/comments.py +++ b/migration/tables/comments.py @@ -57,7 +57,7 @@ async def migrate(entry, storage): if entry.get("createdAt"): reaction_dict["createdAt"] = date_parse(entry.get("createdAt")) shout_oid = entry.get("contentItem") - if not shout_oid in storage["shouts"]["by_oid"]: + if shout_oid not in storage["shouts"]["by_oid"]: if len(storage["shouts"]["by_oid"]) > 0: return shout_oid else: diff --git a/resolvers/topics.py b/resolvers/topics.py index cc8c7d40..2696db80 100644 --- a/resolvers/topics.py +++ b/resolvers/topics.py @@ -89,6 +89,6 @@ async def topics_random(_, info, amount=12): topic_stat = await TopicStat.get_stat(topic.slug) topic.stat = topic_stat if topic_stat["shouts"] > 2: - normalized_topics.push(topic) + normalized_topics.append(topic) sample_length = min(len(normalized_topics), amount) return random.sample(normalized_topics, sample_length) diff --git a/services/zine/shoutscache.py b/services/zine/shoutscache.py index 06062d35..b8f7919d 100644 --- a/services/zine/shoutscache.py +++ b/services/zine/shoutscache.py @@ -170,13 +170,13 @@ class ShoutsCache: shout = session.query(Shout).filter(Shout.slug == a.shout).first() - if not shouts_by_author[a.author]: - shouts_by_author[a.author] = [] + if not shouts_by_author.get(a.user): + shouts_by_author[a.user] = [] - if shout not in shouts_by_author[a.author]: - shouts_by_author[a.author].push(shout) + if shout not in shouts_by_author[a.user]: + shouts_by_author[a.user].append(shout) async with ShoutsCache.lock: - 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 @staticmethod @@ -188,11 +188,12 @@ class ShoutsCache: shout = session.query(Shout).filter(Shout.slug == t.shout).first() - if not shouts_by_topic[t.topic]: + if not shouts_by_topic.get(t.topic): shouts_by_topic[t.topic] = [] if shout not in shouts_by_topic[t.topic]: - shouts_by_topic[t.topic].push(shout) + shouts_by_topic[t.topic].append(shout) + async with ShoutsCache.lock: print("[zine.cache] indexed by %d topics " % len(shouts_by_topic.keys())) ShoutsCache.by_topic = shouts_by_topic