Skip to content

Commit

Permalink
Merge pull request #6364 from tomachalek/query_hist_logging_b
Browse files Browse the repository at this point in the history
Fixes: 1) missing comma in sql call, 2) missing exported task
  • Loading branch information
tomachalek authored Nov 15, 2024
2 parents 8f508a7 + 0ccea03 commit 88b8d13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/plugins/mysql_query_history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ async def get_user_queries(
''', values)
rows = [item for item in await cursor.fetchall()]
full_data = await self._process_rows(plugin_ctx, corpus_factory, rows)

for i, item in enumerate(full_data):
item['idx'] = offset + i

return full_data

async def _process_rows(self, plugin_ctx, corpus_factory, rows):
async def extract_id(item_id: str, item_data: Dict) -> Tuple[str, Dict]:
return item_id, item_data

full_data = []
corpora = CorpusCache(corpus_factory)
qdata_map = {}
Expand Down Expand Up @@ -336,7 +336,7 @@ async def extract_id(item_id: str, item_data: Dict) -> Tuple[str, Dict]:
full_data.append(tmp)
else:
logging.getLogger(__name__).error('Unknown query supertype: ', q_supertype)

return full_data

async def delete_old_records(self):
Expand All @@ -359,7 +359,7 @@ async def delete_old_records(self):
) AS tmp
WHERE row_num > %s
)
'''
''',
(self.preserve_amount,)
)

Expand Down
7 changes: 7 additions & 0 deletions lib/plugins/ucnk_query_history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ async def _delete_indexed_item(self, plugin_ctx, query_id, user_id, created):
data = await resp.json()
raise Exception(f'Failed to delete query from index: {data}')

def export_tasks(self):
"""
For ucnk_query_history, we have to export action to regularly remove old records
so our fulltext index in Camus won't grow indefinitely.
"""
return self.delete_old_records,


@inject(
plugins.runtime.INTEGRATION_DB,
Expand Down

0 comments on commit 88b8d13

Please sign in to comment.