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: add charts to failed-query page #367

Merged
merged 3 commits into from
Sep 25, 2024
Merged

feat: add charts to failed-query page #367

merged 3 commits into from
Sep 25, 2024

Conversation

duyet
Copy link
Owner

@duyet duyet commented Sep 25, 2024

Summary by Sourcery

Add charts to the failed-query page to visualize failed queries over time and by user. Enhance the failed queries configuration with additional descriptions and increased query limits. Update column formats for better data presentation and adjust tests for the CodeDialogFormat component.

New Features:

  • Introduce charts to the failed-query page, including a chart for failed queries over the last 14 days and another chart for failed queries by users over the same period.

Enhancements:

  • Enhance the failed queries configuration by adding a description and increasing the query limit from 100 to 1000.
  • Improve the column formats in the failed queries configuration by adding more detailed formatting options for various columns.

Tests:

  • Update tests for the CodeDialogFormat component to reflect changes in the dialog opening mechanism.

Copy link

vercel bot commented Sep 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 Sep 25, 2024 5:29am

Copy link
Contributor

sourcery-ai bot commented Sep 25, 2024

Reviewer's Guide by Sourcery

This pull request adds charts to the failed-query page and enhances the existing query configuration. The changes include updating the SQL query, modifying column formats, and introducing new chart components for visualizing failed query data.

File-Level Changes

Change Details Files
Enhanced failed queries configuration
  • Added a description to the query configuration
  • Updated SQL query to include more fields and increase the result limit
  • Modified column formats for better data presentation
  • Added new column formats for various fields
  • Introduced related charts configuration for failed query count and failed query count by user
app/[host]/[query]/queries/failed-queries.ts
Updated CodeDialogFormat component
  • Modified CSS selector for open dialog button
  • Updated test cases to reflect changes in the component
components/data-table/cells/code-dialog-format.cy.tsx
Added new chart components
  • Created ChartFailedQueryCount component for visualizing failed query count over time
  • Created ChartFailedQueryCountByType component for visualizing failed query count by user
components/charts/failed-query-count.tsx
components/charts/failed-query-count-by-user.tsx

Sequence Diagram

sequenceDiagram
    participant User
    participant FailedQueryPage
    participant ClickHouse
    participant ChartFailedQueryCount
    participant ChartFailedQueryCountByType

    User->>FailedQueryPage: View failed queries
    FailedQueryPage->>ClickHouse: Fetch failed query data
    ClickHouse-->>FailedQueryPage: Return query results
    FailedQueryPage->>ChartFailedQueryCount: Render failed query count chart
    ChartFailedQueryCount->>ClickHouse: Fetch chart data
    ClickHouse-->>ChartFailedQueryCount: Return chart data
    FailedQueryPage->>ChartFailedQueryCountByType: Render failed query count by user chart
    ChartFailedQueryCountByType->>ClickHouse: Fetch chart data
    ClickHouse-->>ChartFailedQueryCountByType: Return chart data
    FailedQueryPage-->>User: Display failed queries and charts
Loading

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 - here's some feedback:

Overall Comments:

  • The change in the CodeDialogFormat component test from 'button svg[role="open-dialog"]' to 'svg[role="open-dialog"]' seems significant. Can you confirm this is intentional and doesn't affect other parts of the system?
  • Consider adding documentation for the new chart components (ChartFailedQueryCount and ChartFailedQueryCountByType) to facilitate reuse and maintenance.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: 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 to tell me if it was helpful.

FROM system.query_log
WHERE type IN ['ExceptionBeforeStart', 'ExceptionWhileProcessing']
ORDER BY query_start_time DESC
LIMIT 1000
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 implementing pagination instead of increasing the LIMIT

Increasing the LIMIT from 100 to 1000 could potentially impact query performance. Consider implementing a pagination mechanism to fetch results in smaller batches while still allowing access to a larger dataset.

LIMIT 100
OFFSET :offset

initial_user,
multiIf(empty(client_name), http_user_agent, concat(client_name, ' ', toString(client_version_major), '.', toString(client_version_minor), '.', toString(client_version_patch))) AS client,
client_hostname,
toString(databases) AS databases,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider providing a way to view full, structured data

While using toString() makes the data more easily displayable in a table format, it might lose information for complex structures. Consider adding a way to view the full, structured data on demand, perhaps through a expandable cell or a detailed view option.

Suggested change
toString(databases) AS databases,
toString(databases) AS databases,
JSON.stringify(databases) AS databases_full,

import { fetchData } from '@/lib/clickhouse'
import { applyInterval } from '@/lib/clickhouse-query'

export async function ChartFailedQueryCountByType({
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Correct inconsistent naming between file and component

The file is named 'failed-query-count-by-user.tsx', but the component is named 'ChartFailedQueryCountByType'. This inconsistency could lead to confusion. Consider renaming the component to match the file name or vice versa.

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@e7a27d5). Learn more about missing BASE report.
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #367   +/-   ##
=======================================
  Coverage        ?   75.00%           
=======================================
  Files           ?        6           
  Lines           ?      152           
  Branches        ?       55           
=======================================
  Hits            ?      114           
  Misses          ?       38           
  Partials        ?        0           

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

@duyet duyet merged commit 4be031a into main Sep 25, 2024
15 checks passed
@duyet duyet deleted the feat/overview branch September 25, 2024 05:32
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