mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 06:28:53 +00:00
fix: Initialize resource array before using it
This commit is contained in:
1 parent
b0f25778fd
commit
8fb5ca2e8c
1 file changed
+11
-7
+11
-7
@@ -1,12 +1,14 @@
|
|||||||
import { mysql_debug, mysql_slow_query_warning, mysql_ui } from '../config';
|
import { mysql_debug, mysql_slow_query_warning, mysql_ui } from '../config';
|
||||||
import type { CFXParameters } from '../types';
|
import type { CFXParameters } from '../types';
|
||||||
|
|
||||||
|
interface QueryData {
|
||||||
|
date: number;
|
||||||
|
query: string;
|
||||||
|
executionTime: number
|
||||||
|
}
|
||||||
|
|
||||||
type QueryLog = {
|
type QueryLog = {
|
||||||
[invokingResource: string]: {
|
[invokingResource: string]: QueryData[];
|
||||||
date: number;
|
|
||||||
query: string;
|
|
||||||
executionTime: number;
|
|
||||||
}[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const logStorage: QueryLog = {};
|
const logStorage: QueryLog = {};
|
||||||
@@ -20,15 +22,17 @@ export const logQuery = (invokingResource: string, query: string, executionTime:
|
|||||||
|
|
||||||
if (!mysql_ui) return;
|
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() });
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterCommand(
|
RegisterCommand(
|
||||||
'mysql',
|
'mysql',
|
||||||
() => {
|
(source: number) => {
|
||||||
if (!mysql_ui) return;
|
if (!mysql_ui) return;
|
||||||
|
|
||||||
emitNet(`oxmysql:openUi`, logStorage);
|
emitNet(`oxmysql:openUi`, source, logStorage);
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
Reference in new issue
Block a user