-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add CLICKHOUSE_MAX_EXECUTION_TIME
, update fetchData
#264
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,7 +11,7 @@ interface PageProps { | |||||
} | ||||||
|
||||||
export default async function Page({ params: { cluster } }: PageProps) { | ||||||
const replicas = await fetchData<{ replica: string }[]>({ | ||||||
const { data: replicas } = await fetchData<{ replica: string }[]>({ | ||||||
query: `SELECT hostName() as replica FROM clusterAllReplicas({cluster: String}) ORDER BY 1`, | ||||||
query_params: { cluster }, | ||||||
}) | ||||||
|
@@ -47,7 +47,7 @@ export default async function Page({ params: { cluster } }: PageProps) { | |||||
}, | ||||||
} | ||||||
|
||||||
const rows = await fetchData< | ||||||
const { data } = await fetchData< | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consistent destructuring Ensure consistent destructuring of the response object across all fetchData calls for better readability and maintainability.
Suggested change
|
||||||
{ | ||||||
table: string | ||||||
[replica: string]: string | number | ||||||
|
@@ -61,7 +61,7 @@ export default async function Page({ params: { cluster } }: PageProps) { | |||||
<DataTable | ||||||
title={`Total rows of active parts across replicas in the '${cluster}' cluster`} | ||||||
config={config} | ||||||
data={rows} | ||||||
data={data} | ||||||
/> | ||||||
) | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,14 +10,16 @@ import { seeding } from './seeding' | |||||||||||||
export const getCustomDashboards = async () => { | ||||||||||||||
await seeding() | ||||||||||||||
|
||||||||||||||
const dashboards = await fetchData<TableChartsRow[]>({ | ||||||||||||||
const q1 = fetchData<TableChartsRow[]>({ | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (performance): Potential performance improvement Consider using
Suggested change
|
||||||||||||||
query: `SELECT * FROM ${TABLE_CHARTS} FINAL ORDER BY ordering ASC`, | ||||||||||||||
}) | ||||||||||||||
const settings = await fetchData<TableSettingsRow[]>({ | ||||||||||||||
}).then((res) => res.data) | ||||||||||||||
const q2 = fetchData<TableSettingsRow[]>({ | ||||||||||||||
query: `SELECT * FROM ${TABLE_SETTINGS} FINAL`, | ||||||||||||||
}) | ||||||||||||||
}).then((res) => res.data) | ||||||||||||||
|
||||||||||||||
const [dashboards, settings] = await Promise.all([q1, q2]) | ||||||||||||||
|
||||||||||||||
return { settings, dashboards } | ||||||||||||||
return { dashboards, settings } | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export async function updateSettingParams( | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,17 +22,37 @@ export default async function MergeTree({ | |
const engine = await engineType(database, table) | ||
if (engine.includes('MergeTree') === false) return <></> | ||
|
||
const columns = await fetchDataWithCache()<Row[]>({ | ||
const { data: columns } = await fetchDataWithCache()<Row[]>({ | ||
query: config.sql, | ||
query_params: { | ||
database, | ||
table, | ||
}, | ||
}) | ||
|
||
let description = '' | ||
return ( | ||
<DataTable | ||
title={`Table: ${database}.${table}`} | ||
description={<Description database={database} table={table} />} | ||
toolbarExtras={<Extras database={database} table={table} />} | ||
topRightToolbarExtras={ | ||
<TopRightToolbarExtras database={database} table={table} /> | ||
} | ||
config={config} | ||
data={columns} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Potential issue with data structure Ensure that |
||
/> | ||
) | ||
} | ||
|
||
async function Description({ | ||
database, | ||
table, | ||
}: { | ||
database: string | ||
table: string | ||
}) { | ||
try { | ||
const raw = await fetchDataWithCache()<{ comment: string }[]>({ | ||
const { data } = await fetchDataWithCache()<{ comment: string }[]>({ | ||
query: ` | ||
SELECT comment | ||
FROM system.tables | ||
|
@@ -42,23 +62,11 @@ export default async function MergeTree({ | |
query_params: { database, table }, | ||
}) | ||
|
||
description = raw?.[0]?.comment || '' | ||
return data?.[0]?.comment || '' | ||
} catch (e) { | ||
console.error('Error fetching table description', e) | ||
return '' | ||
} | ||
|
||
return ( | ||
<DataTable | ||
title={`Table: ${database}.${table}`} | ||
description={description} | ||
toolbarExtras={<Extras database={database} table={table} />} | ||
topRightToolbarExtras={ | ||
<TopRightToolbarExtras database={database} table={table} /> | ||
} | ||
config={config} | ||
data={columns} | ||
/> | ||
) | ||
} | ||
|
||
const TopRightToolbarExtras = ({ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,10 +22,16 @@ export async function AlternativeTables({ | |||||
}: AlternativeTablesProps) { | ||||||
let anotherTables: { name: string }[] = [] | ||||||
try { | ||||||
anotherTables = await fetchData<{ name: string }[]>({ | ||||||
query: `SELECT name FROM system.tables WHERE database = {database: String}`, | ||||||
const res = await fetchData<{ name: string }[]>({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Variable naming consistency Consider renaming
Suggested change
|
||||||
query: ` | ||||||
SELECT name | ||||||
FROM system.tables | ||||||
WHERE database = {database: String} | ||||||
`, | ||||||
query_params: { database }, | ||||||
}) | ||||||
|
||||||
anotherTables = res.data | ||||||
} catch (error) { | ||||||
console.log(error) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Potential null check issue
Consider adding a null check for
data
before accessing itslength
property to avoid potential runtime errors.