-
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 http-connections and interserver-connections charts #242
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Hey @duyet - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 6 issues found
- 🟡 Security: 2 issues found
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
{ | ||
title: 'Connections', | ||
href: '/charts/connections-http,connections-interserver', | ||
description: 'Number of connections over time', | ||
icon: UnplugIcon, | ||
}, |
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.
suggestion: Consider adding a unique identifier for each menu item.
Adding a unique identifier (e.g., id
) to each menu item can help with tracking and managing menu items more effectively, especially if the list grows or needs to be manipulated programmatically.
{ | |
title: 'Connections', | |
href: '/charts/connections-http,connections-interserver', | |
description: 'Number of connections over time', | |
icon: UnplugIcon, | |
}, | |
{ | |
id: 'connections', | |
title: 'Connections', | |
href: '/charts/connections-http,connections-interserver', | |
description: 'Number of connections over time', | |
icon: UnplugIcon, | |
}, |
@@ -2,6 +2,8 @@ import { NextResponse } from 'next/server' | |||
|
|||
import { fetchData } from '@/lib/clickhouse' | |||
|
|||
export const revalidate = false |
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.
suggestion: Clarify the purpose of disabling revalidation.
It would be helpful to add a comment explaining why revalidation is disabled for this route. This can provide context for future maintainers.
export const revalidate = false | |
export const revalidate = false // Revalidation is disabled to ensure the data remains static and doesn't trigger unnecessary fetches |
|
||
export async function ChartConnectionsHttp({ | ||
title = 'HTTP Connections Last 7 days (Total Requests / Hour)', | ||
interval = 'toStartOfHour', |
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 (security): Consider validating the interval
parameter.
To prevent potential SQL injection or unexpected behavior, consider validating the interval
parameter to ensure it only contains allowed values.
const data = await fetchData< | ||
{ | ||
event_time: string | ||
CurrentMetric_HTTPConnection: number | ||
readable_CurrentMetric_HTTPConnection: string | ||
}[] | ||
>({ |
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): Handle potential errors from fetchData
.
Consider adding error handling for the fetchData
call to manage potential failures gracefully.
|
||
export async function ChartConnectionsInterserver({ | ||
title = 'Interserver Connections Last 7 days (Total Requests / Hour)', | ||
interval = 'toStartOfHour', |
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 (security): Consider validating the interval
parameter.
To prevent potential SQL injection or unexpected behavior, consider validating the interval
parameter to ensure it only contains allowed values.
const data = await fetchData< | ||
{ | ||
event_time: string | ||
CurrentMetric_InterserverConnection: number | ||
readable_CurrentMetric_InterserverConnection: string | ||
}[] | ||
>({ |
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): Handle potential errors from fetchData
.
Consider adding error handling for the fetchData
call to manage potential failures gracefully.
let props = {} | ||
|
||
for (const chart of decodeURIComponent(charts).split(',')) { | ||
console.log(`Rendering chart: ${chart}`) |
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.
suggestion: Remove or replace console.log statements.
Consider removing or replacing console.log
statements with a proper logging mechanism to avoid cluttering the console in production.
console.log(`Rendering chart: ${chart}`) | |
import { log } from 'some-logging-library'; | |
... | |
log.info(`Rendering chart: ${chart}`); |
(await import(`@/components/charts/${chart}`)).default | ||
) | ||
} catch (e) { | ||
console.error(`Error rendering chart: ${chart}`, e) |
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.
suggestion: Improve error handling for chart rendering.
Consider providing more user-friendly feedback or fallback UI in case of errors when rendering charts, rather than just logging the error.
console.error(`Error rendering chart: ${chart}`, e) | |
console.error(`Error rendering chart: ${chart}`, e) | |
alert('An error occurred while rendering the chart. Please try again later.') |
Resolved #103