all authors and some logs
This commit is contained in:
parent
43cf5ea361
commit
d62342880b
|
@ -206,9 +206,10 @@ async def load_authors_by(_, info, by, limit, offset):
|
|||
).order_by(
|
||||
by.get("order") or "createdAt"
|
||||
).limit(limit).offset(offset)
|
||||
print(aq)
|
||||
authors = list(map(lambda r: r.User, session.execute(aq)))
|
||||
if by.get("stat"):
|
||||
for a in authors:
|
||||
a.stat = await get_author_stat(a.slug)
|
||||
authors = list(set(authors)).sort(lambda a: a["stat"].get(by.get("stat")))
|
||||
authors = list(set(authors)).sort(authors, key=lambda a: a["stat"].get(by.get("stat")))
|
||||
return authors
|
||||
|
|
|
@ -168,22 +168,25 @@ class ReactedStorage:
|
|||
self = ReactedStorage
|
||||
all_reactions = session.query(Reaction).all()
|
||||
self.modified_shouts = list(set([r.shout for r in all_reactions]))
|
||||
print("[stat.reacted] %d shouts with reactions loaded" % len(self.modified_shouts))
|
||||
print("[stat.reacted] %d shouts with reactions" % len(self.modified_shouts))
|
||||
|
||||
@staticmethod
|
||||
async def recount_changed(session):
|
||||
self = ReactedStorage
|
||||
async with self.lock:
|
||||
print('[stat.reacted] recounting...')
|
||||
for slug in list(self.modified_shouts):
|
||||
sss = list(self.modified_shouts)
|
||||
c = 0
|
||||
for slug in sss:
|
||||
siblings = session.query(Reaction).where(Reaction.shout == slug).all()
|
||||
c += len(siblings)
|
||||
await self.recount(siblings)
|
||||
|
||||
print("[stat.reacted] %d reactions total" % c)
|
||||
print("[stat.reacted] %d shouts" % len(self.modified_shouts))
|
||||
print("[stat.reacted] %d topics" % len(self.reacted["topics"].values()))
|
||||
print("[stat.reacted] %d shouts" % len(self.reacted["shouts"]))
|
||||
print("[stat.reacted] %d authors" % len(self.reacted["authors"].values()))
|
||||
print("[stat.reacted] %d reactions" % len(self.reacted["reactions"]))
|
||||
print("[stat.reacted] %d reactions replied" % len(self.reacted["reactions"]))
|
||||
self.modified_shouts = set([])
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -19,7 +19,7 @@ class TopicStat:
|
|||
async def load_stat(session):
|
||||
self = TopicStat
|
||||
shout_topics = session.query(ShoutTopic).all()
|
||||
print("[stat.topics] shouts linked %d times" % len(shout_topics))
|
||||
print("[stat.topics] %d links for shouts" % len(shout_topics))
|
||||
for shout_topic in shout_topics:
|
||||
tpc = shout_topic.topic
|
||||
# shouts by topics
|
||||
|
@ -34,17 +34,14 @@ class TopicStat:
|
|||
[aslug, acaption] = a
|
||||
self.authors_by_topic[tpc][aslug] = acaption
|
||||
|
||||
print("[stat.topics] shouts indexed by %d topics" % len(self.shouts_by_topic.keys()))
|
||||
print("[stat.topics] authors indexed by %d topics" % len(self.authors_by_topic.keys()))
|
||||
|
||||
self.followers_by_topic = {}
|
||||
followings = session.query(TopicFollower).all()
|
||||
print("[stat.topics] %d followings by users" % len(followings))
|
||||
for flw in followings:
|
||||
topic = flw.topic
|
||||
userslug = flw.follower
|
||||
self.followers_by_topic[topic] = self.followers_by_topic.get(topic, dict())
|
||||
self.followers_by_topic[topic][userslug] = userslug
|
||||
print("[stat.topics] followers indexed by %d topics" % len(self.followers_by_topic.keys()))
|
||||
|
||||
@staticmethod
|
||||
async def get_shouts(topic):
|
||||
|
|
|
@ -17,7 +17,10 @@ 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])
|
||||
print("[zine.shouts] %d shouts indexed by authors" % len(self.authors_by_shout))
|
||||
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):
|
||||
|
@ -42,7 +45,7 @@ class ShoutAuthorStorage:
|
|||
with local_session() as session:
|
||||
async with self.lock:
|
||||
await self.load(session)
|
||||
print("[zine.shouts] index by authors was updated")
|
||||
print("[zine.authors] index by authors was updated")
|
||||
except Exception as err:
|
||||
print("[zine.shouts] error indexing by author: %s" % (err))
|
||||
print("[zine.authors] error indexing by author: %s" % (err))
|
||||
await asyncio.sleep(self.period)
|
||||
|
|
Loading…
Reference in New Issue
Block a user