add viewShout

This commit is contained in:
knst-kotov
2021-09-27 17:59:44 +03:00
parent f23d375b4d
commit 6e451c8095
4 changed files with 47 additions and 4 deletions

View File

@@ -165,6 +165,17 @@ class TopShouts:
print("top shouts worker error = %s" % (err))
await asyncio.sleep(TopShouts.period)
async def db_flush_worker():
print("db flush worker start")
while True:
try:
print("flush changes")
with local_session() as session:
view_storage.flush_changes(session)
except Exception as err:
print("db flush worker error = %s" % (err))
await asyncio.sleep(30*60)
@query.field("topShoutsByView")
async def top_shouts_by_view(_, info, limit):
@@ -284,6 +295,11 @@ async def rate_shout(_, info, shout_id, value):
return {"error" : ""}
@mutation.field("viewShout")
async def view_shout(_, info, shout_id):
view_storage.inc_view(shout_id)
return {"error" : ""}
@query.field("getShoutBySlug")
async def get_shout_by_slug(_, info, slug):
slug_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]