resolvers, orm, migration, schema fixes

This commit is contained in:
2022-08-14 15:48:35 +03:00
parent 3bda452455
commit ab9d03aac6
13 changed files with 211 additions and 207 deletions

View File

@@ -12,14 +12,10 @@ class ShoutAuthorStorage:
@staticmethod
async def load(session):
self = ShoutAuthorStorage
authors = session.query(ShoutAuthor).all()
for author in authors:
user = author.user
shout = author.shout
if shout in self.authors_by_shout:
self.authors_by_shout[shout].append(user)
else:
self.authors_by_shout[shout] = [user]
sas = session.query(ShoutAuthor).all()
for sa in sas:
self.authors_by_shout[sa.shout] = self.authors_by_shout.get(sa.shout, [])
self.authors_by_shout[sa.shout].append([sa.user, sa.caption])
print('[zine.authors] %d shouts preprocessed' % len(self.authors_by_shout))
@staticmethod
@@ -28,6 +24,15 @@ class ShoutAuthorStorage:
async with self.lock:
return self.authors_by_shout.get(shout, [])
@staticmethod
async def get_author_caption(shout, author):
self = ShoutAuthorStorage
async with self.lock:
for a in self.authors_by_shout.get(shout, []):
if author in a:
return a[1]
return { "error": "author caption not found" }
@staticmethod
async def worker():
self = ShoutAuthorStorage