fixes
This commit is contained in:
parent
bae0be1c7d
commit
79e112c36f
|
@ -16,39 +16,39 @@ from sqlalchemy.orm import selectinload
|
|||
|
||||
|
||||
@query.field("topViewed")
|
||||
async def top_viewed(_, info, page, size):
|
||||
async def top_viewed(_, _info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_top_viewed[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_top_viewed()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@query.field("topMonth")
|
||||
async def top_month(_, info, page, size):
|
||||
async def top_month(_, _info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_top_month[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_top_month()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@query.field("topOverall")
|
||||
async def top_overall(_, info, page, size):
|
||||
async def top_overall(_, _info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_top_overall[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_top_overall()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@query.field("recentPublished")
|
||||
async def recent_published(_, info, page, size):
|
||||
async def recent_published(_, _info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_recent_published[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_recent_published()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@query.field("recentAll")
|
||||
async def recent_all(_, info, page, size):
|
||||
async def recent_all(_, _info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_recent_all[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_recent_all()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@query.field("recentReacted")
|
||||
async def recent_reacted(_, info, page, size):
|
||||
async with ShoutsCache.lock:
|
||||
return ShoutsCache.get_recent_reacted[((page - 1) * size) : (page * size)]
|
||||
return ShoutsCache.get_recent_reacted()[((page - 1) * size) : (page * size)]
|
||||
|
||||
|
||||
@mutation.field("viewShout")
|
||||
|
|
|
@ -216,11 +216,11 @@ class ReactedStorage:
|
|||
|
||||
@staticmethod
|
||||
async def flush_changes(session):
|
||||
self = ReactedStorage()
|
||||
self = ReactedStorage
|
||||
async with self.lock:
|
||||
for slug in dict(self.reacted['shouts']).keys():
|
||||
topics = session.query(ShoutTopic.topic).where(ShoutTopic.shout == slug).all()
|
||||
reactions = self.reacted['shouts'][slug]
|
||||
reactions = self.reacted['shouts'].get(slug, [])
|
||||
for ts in list(topics):
|
||||
try:
|
||||
tslug = ts.pop()
|
||||
|
@ -238,6 +238,7 @@ class ReactedStorage:
|
|||
session.add(reaction)
|
||||
flag_modified(reaction, "value")
|
||||
reaction.modified = False
|
||||
print('flushing')
|
||||
for reaction in self.to_flush:
|
||||
session.add(reaction)
|
||||
self.to_flush.clear()
|
||||
|
|
|
@ -22,18 +22,16 @@ class TopicStat:
|
|||
for shout_topic in shout_topics:
|
||||
topic = shout_topic.topic
|
||||
shout = shout_topic.shout
|
||||
if topic in self.shouts_by_topic:
|
||||
if not self.shouts_by_topic.get(topic):
|
||||
self.shouts_by_topic[topic] = []
|
||||
if shout not in self.shouts_by_topic[topic]:
|
||||
self.shouts_by_topic[topic].append(shout)
|
||||
else:
|
||||
self.shouts_by_topic[topic] = [
|
||||
shout,
|
||||
]
|
||||
|
||||
authors = await ShoutAuthorStorage.get_authors(shout)
|
||||
if topic in self.authors_by_topic:
|
||||
self.authors_by_topic[topic].update(authors)
|
||||
else:
|
||||
self.authors_by_topic[topic] = set(authors)
|
||||
self.authors_by_topic[topic] = list(set(authors))
|
||||
|
||||
print("[stat.topics] authors sorted")
|
||||
print("[stat.topics] shouts sorted")
|
||||
|
@ -46,7 +44,7 @@ class TopicStat:
|
|||
if topic in self.followers_by_topic:
|
||||
self.followers_by_topic[topic].append(user)
|
||||
else:
|
||||
self.followers_by_topic[topic] = [user]
|
||||
self.followers_by_topic[topic] = [user, ]
|
||||
print("[stat.topics] followers sorted")
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue
Block a user