- feat(nexus): Increase amount of logging

1 internal commit(s)

GitOrigin-RevId: 1baac946df3ea7cdf452bc880bb0d4764f6fc65e
This commit is contained in:
the-superpirate 2021-04-13 10:39:00 +03:00
parent c623e67a6d
commit b4a624fa12
7 changed files with 30 additions and 13 deletions

View File

@ -22,7 +22,7 @@ class DownloadHandler(BaseCallbackQueryHandler):
self.application.user_manager.last_widget[request_context.chat.chat_id] = None
request_context.add_default_fields(mode='download', session_id=session_id)
request_context.statbox(action='get', query=str(document_id), position=position)
request_context.statbox(action='get', document_id=document_id, position=position, schema=schema)
typed_document_pb = await self.get_typed_document_pb(
schema=schema,

View File

@ -36,7 +36,8 @@ class ReferencingToHandler(BaseCallbackQueryHandler):
request_context.statbox(
action=action,
duration=time.time() - start_time,
query=f'{document_id}',
document_id=document_id,
schema='scimag',
)
serp, buttons = await document_list_widget.render()

View File

@ -13,7 +13,7 @@ from .base import BaseHandler
class ViewHandler(BaseHandler):
filter = events.NewMessage(incoming=True, pattern='^/v([abcm])([sr])?_([A-Za-z0-9]+)_([0-9]+)_([0-9]+)_'
filter = events.NewMessage(incoming=True, pattern='^/v([ab])([sr])?_([A-Za-z0-9]+)_([0-9]+)_([0-9]+)_'
'([0-9]+)')
should_reset_last_widget = False
@ -29,7 +29,7 @@ class ViewHandler(BaseHandler):
page = int(position / self.application.config['application']['page_size'])
request_context.add_default_fields(mode='view', session_id=session_id)
request_context.statbox(action='view', query=str(document_id), position=position)
request_context.statbox(action='view', document_id=document_id, position=position, schema=schema)
found_old_widget = old_message_id == self.application.user_manager.last_widget.get(request_context.chat.chat_id)
try:

View File

@ -13,12 +13,14 @@ from .base import BaseCallbackQueryHandler
class VoteHandler(BaseCallbackQueryHandler):
filter = events.CallbackQuery(pattern='^/vote_([A-Za-z0-9]+)_([0-9]+)_([bo])$')
filter = events.CallbackQuery(pattern='^/vote([ab])?_([A-Za-z0-9]+)_([0-9]+)_([bo])$')
async def handler(self, event: events.ChatAction, request_context: RequestContext):
session_id = event.pattern_match.group(1).decode()
document_id = int(event.pattern_match.group(2).decode())
vote = event.pattern_match.group(3).decode()
short_schema = event.pattern_match.group(1)
schema = self.short_schema_to_schema(short_schema) if short_schema else None
session_id = event.pattern_match.group(2).decode()
document_id = int(event.pattern_match.group(3).decode())
vote = event.pattern_match.group(4).decode()
vote_value = {'b': -1, 'o': 1}[vote]
request_context.add_default_fields(mode='vote', session_id=session_id)
@ -33,6 +35,7 @@ class VoteHandler(BaseCallbackQueryHandler):
request_context.statbox(
action='vote',
document_id=document_id,
schema=schema,
)
logging.getLogger('operation').info(
msg=MessageToDict(document_operation_pb),

View File

@ -54,12 +54,14 @@ class BaseHubService(BaseService):
buttons = [
vote_button(
case='broken',
schema=document_view.schema,
document_id=document_id,
language=request_context.chat.language,
session_id=session_id,
),
vote_button(
case='ok',
schema=document_view.schema,
document_id=document_id,
language=request_context.chat.language,
session_id=session_id,
@ -77,6 +79,7 @@ class BaseHubService(BaseService):
request_context.statbox(
action='sent',
document_id=document_id,
schema=document_view.schema,
voting=voting,
)
return message

View File

@ -123,6 +123,7 @@ class DownloadTask:
action='missed',
duration=time.time() - start_time,
document_id=document_view.id,
schema=document_view.schema,
)
is_served_from_sharience = False
if self.delivery_service.is_sharience_enabled:
@ -135,6 +136,7 @@ class DownloadTask:
action='not_found',
document_id=document_view.id,
duration=time.time() - start_time,
schema=document_view.schema,
)
await self.respond_not_found(
request_context=request_context,
@ -147,6 +149,7 @@ class DownloadTask:
duration=time.time() - start_time,
document_id=document_view.id,
len=len(file),
schema=document_view.schema,
)
progress_bar_upload = ProgressBar(
@ -171,6 +174,7 @@ class DownloadTask:
action='uploaded',
duration=time.time() - start_time,
document_id=document_view.id,
schema=document_view.schema,
)
if self.delivery_service.should_store_hashes:
asyncio.create_task(self.store_hashes(
@ -185,6 +189,7 @@ class DownloadTask:
action='user_canceled',
duration=time.time() - start_time,
document_id=document_view.id,
schema=document_view.schema,
)
except asyncio.CancelledError:
pass
@ -215,7 +220,7 @@ class DownloadTask:
async def try_sharience(self, request_context, document_view):
if document_view.doi:
request_context.statbox(action='try_sharience', doi=document_view.doi)
request_context.statbox(action='try_sharience', doi=document_view.doi, schema=document_view.schema)
pg_data = await self.delivery_service.pool_holder.execute(
'''
select sh.id, sh.telegram_file_id as vote_sum
@ -273,7 +278,11 @@ class DownloadTask:
async def external_cancel(self):
self.task.cancel()
self.request_context.statbox(action='externally_canceled')
self.request_context.statbox(
action='externally_canceled',
document_id=self.document_view.id,
schema=self.document_view.schema,
)
await self.delivery_service.telegram_client.send_message(
self.request_context.chat.chat_id,
t("DOWNLOAD_CANCELED", language=self.request_context.chat.language).format(
@ -372,7 +381,7 @@ class DeliveryService(DeliveryServicer, BaseHubService):
request_context=request_context,
voting=not is_group_or_channel(request_context.chat.chat_id),
)
request_context.statbox(action='cache_hit', document_id=document_view.id)
request_context.statbox(action='cache_hit', document_id=document_view.id, schema=document_view.schema)
except ValueError:
cache_hit = False
if not cache_hit:

View File

@ -30,12 +30,13 @@ def close_button(session_id: str = None):
)
def vote_button(language: str, session_id: str, document_id: int, case: str):
def vote_button(language: str, session_id: str, schema: str, document_id: int, case: str):
label = f"REPORT_{case.upper()}_FILE"
case = {'broken': 'b', 'ok': 'o'}[case]
schema = {'scimag': 'a', 'scitech': 'b'}[schema]
return Button.inline(
text=t(label, language=language),
data=f'/vote_{session_id}_{document_id}_{case}',
data=f'/vote{schema}_{session_id}_{document_id}_{case}',
)