feat(nui): Display slow queries with yellow text color

This commit is contained in:
Luke committed 2022-01-27 17:23:45 +01:00
1 parent 31fb361c4c
commit b0ea8e1172
2 files changed
+15 -2

No files matched your search

+7 -1
View File
@@ -5,6 +5,7 @@ interface QueryData {
date: number;
query: string;
executionTime: number;
slow?: boolean;
}
type QueryLog = Record<string, QueryData[]>;
@@ -21,7 +22,12 @@ export const logQuery = (invokingResource: string, query: string, executionTime:
if (!mysql_ui) return;
if (logStorage[invokingResource] === undefined) logStorage[invokingResource] = [];
logStorage[invokingResource].push({ query, executionTime, date: Date.now() });
logStorage[invokingResource].push({
query,
executionTime,
date: Date.now(),
slow: executionTime >= mysql_slow_query_warning ? true : undefined,
});
};
RegisterCommand(
+8 -1
View File
@@ -17,11 +17,13 @@ interface QueryData {
date: number;
query: string;
executionTime: number;
slow?: boolean;
}
interface TableData {
query: string;
executionTime: number;
slow?: boolean;
}
interface NuiData {
@@ -54,6 +56,10 @@ const Resource: React.FC = () => {
Header: 'Execution time (ms)',
accessor: 'executionTime',
},
{
Header: 'Slow',
accessor: 'slow',
},
],
[]
);
@@ -76,7 +82,7 @@ const Resource: React.FC = () => {
{
columns,
data,
initialState: { pageSize: 12 },
initialState: { pageSize: 12, hiddenColumns: ['slow'] },
manualPagination: true,
manualSortBy: true,
pageCount: totalPages,
@@ -140,6 +146,7 @@ const Resource: React.FC = () => {
{...cell.getCellProps()}
fontFamily="Poppins"
borderBottomColor="#313C4A"
color={row.values.slow && '#f3eca1'}
isTruncated={cell.column.id === 'query'}
textAlign={cell.column.id === 'executionTime' ? 'center' : 'left'}
>