remove topAuthors
This commit is contained in:
parent
a91711df4b
commit
b26ff8ee77
|
@ -153,31 +153,6 @@ class ShoutsCache:
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
ShoutsCache.top_viewed = shouts
|
ShoutsCache.top_viewed = shouts
|
||||||
|
|
||||||
'''
|
|
||||||
@staticmethod
|
|
||||||
async def prepare_top_authors():
|
|
||||||
month_ago = datetime.now() - timedelta(days = 30)
|
|
||||||
with local_session() as session:
|
|
||||||
shout_with_view = select(Shout.slug, func.sum(ShoutViewByDay.value).label("view")).\
|
|
||||||
join(ShoutViewByDay).\
|
|
||||||
where(and_(ShoutViewByDay.day > month_ago, Shout.publishedAt != None)).\
|
|
||||||
group_by(Shout.slug).\
|
|
||||||
order_by(desc("view")).cte()
|
|
||||||
stmt = select(ShoutAuthor.user, func.sum(shout_with_view.c.view).label("view")).\
|
|
||||||
join(shout_with_view, ShoutAuthor.shout == shout_with_view.c.slug).\
|
|
||||||
group_by(ShoutAuthor.user).\
|
|
||||||
order_by(desc("view")).\
|
|
||||||
limit(ShoutsCache.limit)
|
|
||||||
authors = {}
|
|
||||||
for row in session.execute(stmt):
|
|
||||||
authors[row.user] = row.view
|
|
||||||
authors_ids = authors.keys()
|
|
||||||
authors = session.query(User).filter(User.id.in_(authors_ids)).all()
|
|
||||||
async with ShoutsCache.lock:
|
|
||||||
ShoutsCache.top_authors = authors
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def worker():
|
async def worker():
|
||||||
print("shouts cache worker start")
|
print("shouts cache worker start")
|
||||||
|
@ -188,7 +163,6 @@ class ShoutsCache:
|
||||||
await ShoutsCache.prepare_top_overall()
|
await ShoutsCache.prepare_top_overall()
|
||||||
await ShoutsCache.prepare_top_viewed()
|
await ShoutsCache.prepare_top_viewed()
|
||||||
await ShoutsCache.prepare_recent_shouts()
|
await ShoutsCache.prepare_recent_shouts()
|
||||||
# await ShoutsCache.prepare_top_authors()
|
|
||||||
print("shouts cache update finished")
|
print("shouts cache update finished")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("shouts cache worker error = %s" % (err))
|
print("shouts cache worker error = %s" % (err))
|
||||||
|
@ -214,7 +188,6 @@ class ShoutSubscriptions:
|
||||||
for subs in ShoutSubscriptions.subscriptions:
|
for subs in ShoutSubscriptions.subscriptions:
|
||||||
subs.put_nowait(shout)
|
subs.put_nowait(shout)
|
||||||
|
|
||||||
|
|
||||||
@query.field("topViewed")
|
@query.field("topViewed")
|
||||||
async def top_viewed(_, info, limit):
|
async def top_viewed(_, info, limit):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
|
@ -235,13 +208,6 @@ async def recent_shouts(_, info, limit):
|
||||||
async with ShoutsCache.lock:
|
async with ShoutsCache.lock:
|
||||||
return ShoutsCache.recent_shouts[:limit]
|
return ShoutsCache.recent_shouts[:limit]
|
||||||
|
|
||||||
|
|
||||||
# @query.field("topAuthors")
|
|
||||||
# async def top_authors(_, info, limit):
|
|
||||||
# async with ShoutsCache.lock:
|
|
||||||
# return ShoutsCache.top_authors[:limit]
|
|
||||||
|
|
||||||
|
|
||||||
@mutation.field("createShout")
|
@mutation.field("createShout")
|
||||||
@login_required
|
@login_required
|
||||||
async def create_shout(_, info, input):
|
async def create_shout(_, info, input):
|
||||||
|
|
|
@ -164,7 +164,6 @@ type Query {
|
||||||
topMonth(limit: Int): [Shout]!
|
topMonth(limit: Int): [Shout]!
|
||||||
topOverall(limit: Int): [Shout]!
|
topOverall(limit: Int): [Shout]!
|
||||||
recents(limit: Int): [Shout]!
|
recents(limit: Int): [Shout]!
|
||||||
topAuthors(limit: Int): [User]!
|
|
||||||
|
|
||||||
# topics
|
# topics
|
||||||
topicsBySlugs(slugs: [String]): [Topic]!
|
topicsBySlugs(slugs: [String]): [Topic]!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user