shoutscache, format

This commit is contained in:
2022-09-07 19:19:06 +03:00
parent 742042398c
commit 365c2f25e7
9 changed files with 129 additions and 33 deletions

View File

@@ -11,8 +11,8 @@ class TopicStorage:
self = TopicStorage
topics = session.query(Topic)
self.topics = dict([(topic.slug, topic) for topic in topics])
for topic in self.topics.values():
self.load_parents(topic)
for tpc in self.topics.values():
self.load_parents(tpc)
print("[zine.topics] %d precached" % len(self.topics.keys()))
@@ -51,7 +51,16 @@ class TopicStorage:
return list(topics)
@staticmethod
async def add_topic(topic):
async def get_topics_by_author(author):
self = TopicStorage
async with self.lock:
topics = filter(
lambda topic: topic.community == author, self.topics.values()
)
return list(topics)
@staticmethod
async def update_topic(topic):
self = TopicStorage
async with self.lock:
self.topics[topic.slug] = topic