Skip to content
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: enhance query detail page with cluster support and improve UI components #431

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

duyet
Copy link
Owner

@duyet duyet commented Nov 25, 2024

Summary by Sourcery

Enhance query handling by adding support for executing queries across clusters and refactor UI components to improve the user interface and code maintainability.

New Features:

  • Introduce cluster support in query handling, allowing queries to be executed across clusters.

Enhancements:

  • Refactor UI components for query details, including the addition of new components like QueryDetailBadge, QueryDetailCard, and DropdownCluster to improve modularity and maintainability.

Copy link

vercel bot commented Nov 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clickhouse-monitoring ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 3:00pm

Copy link
Contributor

sourcery-ai bot commented Nov 25, 2024

Reviewer's Guide by Sourcery

This PR enhances the query handling functionality by adding cluster support and improves UI components through code refactoring. The changes introduce the ability to query across different clusters while maintaining a cleaner, more modular component structure.

Sequence diagram for fetching query details with cluster support

sequenceDiagram
    participant User
    participant QueryDetail
    participant DropdownCluster
    participant QueryDetailCard
    participant ClickHouse
    User->>QueryDetail: Request query details
    QueryDetail->>DropdownCluster: Initialize cluster dropdown
    DropdownCluster->>ClickHouse: Fetch cluster data
    ClickHouse-->>DropdownCluster: Return cluster data
    QueryDetail->>QueryDetailCard: Initialize query detail card
    QueryDetailCard->>ClickHouse: Fetch query data
    ClickHouse-->>QueryDetailCard: Return query data
    QueryDetailCard-->>User: Display query details
Loading

Class diagram for QueryDetail and related components

classDiagram
    class QueryDetail {
        +QueryDetail(queryConfig, params, searchParams)
    }
    class QueryDetailCard {
        +QueryDetailCard(queryConfig, params, searchParams)
    }
    class QueryDetailBadge {
        +QueryDetailBadge(queryConfig, params, searchParams)
    }
    class DropdownCluster {
        +DropdownCluster(params, searchParams, className)
    }
    QueryDetail --> QueryDetailCard
    QueryDetail --> QueryDetailBadge
    QueryDetail --> DropdownCluster
    QueryDetailCard --> ErrorAlert
    QueryDetailCard --> TruncatedList
    QueryDetailCard --> TruncatedParagraph
    QueryDetailCard --> Accordion
    QueryDetailCard --> fetchData
    QueryDetailBadge --> Badge
    QueryDetailBadge --> fetchData
    DropdownCluster --> ErrorAlert
    DropdownCluster --> Button
    DropdownCluster --> DropdownMenu
    DropdownCluster --> fetchData
Loading

File-Level Changes

Change Details Files
Refactored query detail component into smaller, more focused components
  • Split large QueryDetail component into QueryDetailCard, QueryDetailBadge, and DropdownCluster
  • Added loading states with skeleton components
  • Implemented Suspense boundaries for better loading experience
app/[host]/query/[query_id]/query-detail.tsx
app/[host]/query/[query_id]/query-detail-card.tsx
app/[host]/query/[query_id]/query-detail-badge.tsx
app/[host]/query/[query_id]/dropdown-cluster.tsx
Added cluster support for query execution
  • Implemented cluster selection dropdown component
  • Modified SQL query to support cluster-wide queries
  • Added cluster parameter handling in page component
app/[host]/query/[query_id]/dropdown-cluster.tsx
app/[host]/query/[query_id]/page.tsx
lib/clickhouse.ts
Enhanced ClickHouse client configuration and query handling
  • Refactored client configuration to support custom client configs
  • Updated fetchData function to handle cluster-specific queries
  • Improved error handling and logging
lib/clickhouse.ts
components/clickhouse-host.tsx
components/table.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@duyet duyet changed the title feat: enhance query handling with cluster support and improve UI components feat: enhance query detail page with cluster support and improve UI components Nov 25, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

import { type RowData } from './config'
import { PageProps } from './types'

export async function QueryDetailBadge({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider lifting data fetching to parent component to avoid duplicate queries

This component and QueryDetailCard are fetching the same data. Consider fetching once in a parent component and passing the data down to both children to improve performance.

export function QueryDetailBadge({
  queryConfig,
  params,
  queryData,
}: {
  queryConfig: RowData
  params: PageProps
  queryData: any
}) {

Comment on lines +82 to +84
const config = clientConfig
? clientConfig
: getClickHouseConfigs()[hostId || getHostId()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Avoid unneeded ternary statements (simplify-ternary)

Suggested change
const config = clientConfig
? clientConfig
: getClickHouseConfigs()[hostId || getHostId()]
const config = clientConfig || getClickHouseConfigs()[hostId || getHostId()]


ExplanationIt is possible to simplify certain ternary statements into either use of an || or !.
This makes the code easier to read, since there is no conditional logic.

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 77.16%. Comparing base (8eb72f3) to head (d3afc9a).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/clickhouse.ts 33.33% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #431      +/-   ##
==========================================
- Coverage   78.34%   77.16%   -1.19%     
==========================================
  Files           5        5              
  Lines         157      162       +5     
  Branches       58       60       +2     
==========================================
+ Hits          123      125       +2     
- Misses         31       34       +3     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2024

Bundle Report

Changes will increase total bundle size by 4.8kB (0.07%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
clickhouse-monitoring-bundle-server-cjs 2.55MB 3.85kB (0.15%) ⬆️
clickhouse-monitoring-bundle-edge-server-array-push 128.52kB 6 bytes (-0.0%) ⬇️
clickhouse-monitoring-bundle-client-array-push 3.79MB 957 bytes (0.03%) ⬆️

@duyet duyet merged commit f36e38e into main Nov 25, 2024
22 checks passed
@duyet duyet deleted the chore/ui-update branch November 25, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants