fix: Initialize resource array before using it

This commit is contained in:
Luke committed 2021-12-26 21:34:29 +01:00
1 parent b0f25778fd
commit 8fb5ca2e8c
1 file changed
+11 -7
+11 -7
View File
@@ -1,12 +1,14 @@
import { mysql_debug, mysql_slow_query_warning, mysql_ui } from '../config';
import type { CFXParameters } from '../types';
interface QueryData {
date: number;
query: string;
executionTime: number
}
type QueryLog = {
[invokingResource: string]: {
date: number;
query: string;
executionTime: number;
}[];
[invokingResource: string]: QueryData[];
};
const logStorage: QueryLog = {};
@@ -20,15 +22,17 @@ 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() });
};
RegisterCommand(
'mysql',
() => {
(source: number) => {
if (!mysql_ui) return;
emitNet(`oxmysql:openUi`, logStorage);
emitNet(`oxmysql:openUi`, source, logStorage);
},
true
);