code review, all authors query restored
This commit is contained in:
12
services/zine/authors.py
Normal file
12
services/zine/authors.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from base.orm import local_session
|
||||
from orm.user import User
|
||||
from orm.shout import ShoutAuthor
|
||||
|
||||
|
||||
class AuthorsStorage:
|
||||
@staticmethod
|
||||
async def get_all_authors():
|
||||
with local_session() as session:
|
||||
query = session.query(User).join(ShoutAuthor)
|
||||
result = query.all()
|
||||
return result
|
@@ -6,7 +6,6 @@ from orm.shout import ShoutAuthor, Shout
|
||||
|
||||
class ShoutAuthorStorage:
|
||||
authors_by_shout = {}
|
||||
shouts_by_author = {}
|
||||
lock = asyncio.Lock()
|
||||
period = 30 * 60 # sec
|
||||
|
||||
@@ -17,10 +16,7 @@ class ShoutAuthorStorage:
|
||||
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])
|
||||
self.shouts_by_author[sa.user] = self.shouts_by_author.get(sa.user, [])
|
||||
self.shouts_by_author[sa.user].append(sa.shout)
|
||||
print("[zine.authors] %d shouts indexed by authors" % len(self.authors_by_shout))
|
||||
print("[zine.authors] %d authors indexed by shouts" % len(self.shouts_by_author))
|
||||
|
||||
@staticmethod
|
||||
async def get_authors(shout):
|
||||
|
Reference in New Issue
Block a user