basic logging
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
1b8e3d31db
commit
170250d4d0
@@ -15,11 +15,12 @@ export const ch = createClient({
|
|||||||
export async function chQueryWithMeta<T extends Record<string, any>>(
|
export async function chQueryWithMeta<T extends Record<string, any>>(
|
||||||
query: string
|
query: string
|
||||||
): Promise<ResponseJSON<T>> {
|
): Promise<ResponseJSON<T>> {
|
||||||
|
const start = Date.now();
|
||||||
const res = await ch.query({
|
const res = await ch.query({
|
||||||
query,
|
query,
|
||||||
});
|
});
|
||||||
const json = await res.json<T>();
|
const json = await res.json<T>();
|
||||||
return {
|
const response = {
|
||||||
...json,
|
...json,
|
||||||
data: json.data.map((item) => {
|
data: json.data.map((item) => {
|
||||||
const keys = Object.keys(item);
|
const keys = Object.keys(item);
|
||||||
@@ -35,6 +36,10 @@ export async function chQueryWithMeta<T extends Record<string, any>>(
|
|||||||
}, {} as T);
|
}, {} as T);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
console.log(`Clickhouse query took ${response.statistics?.elapsed}ms`);
|
||||||
|
console.log(`chQuery took ${Date.now() - start}ms`);
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function chQuery<T extends Record<string, any>>(
|
export async function chQuery<T extends Record<string, any>>(
|
||||||
|
|||||||
Reference in New Issue
Block a user