fixes
This commit is contained in:
parent
e38d478ef2
commit
bae0be1c7d
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user