Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 21, 2025

Prevents unnecessary API calls to /viewer/json/render when the GraphShardExists capability is disabled.

Problem

Previously, MetricChart components would make API calls to the /viewer/json/render endpoint regardless of whether GraphShard was enabled in the database capabilities. This resulted in:

  • Unnecessary network requests when GraphShard is disabled
  • Potential API errors that needed to be handled
  • Inefficient resource usage

While the UI would hide charts when GraphShardExists=false, the underlying API calls were still being made.

Solution

Added a capability check to MetricChart that uses RTK Query's skip option to conditionally prevent API calls:

const {currentData, error, isFetching, status} = chartApi.useGetChartDataQuery(
    {
        database,
        metrics,
        timeFrame,
        maxDataPoints,
    },
    {
        pollingInterval: autorefresh,
        skip: !graphShardExists, // Skip API call when GraphShard is disabled
    },
);

Behavior

When GraphShardExists=true:

  • Charts make API calls and display data normally
  • Existing functionality unchanged

When GraphShardExists=false:

  • No API calls to /viewer/json/render are made
  • Charts report loading state to maintain consistent UI behavior
  • Dashboard remains hidden (existing TenantDashboard logic preserved)

Impact

  • Eliminates unnecessary API calls when GraphShard is disabled
  • Improves network efficiency and reduces server load
  • Maintains all existing UI behavior and fallback mechanisms
  • Affects all chart components: TenantDashboard, QueriesActivityCharts

This change addresses the root cause more efficiently than the previous approach of making API calls and then conditionally displaying results.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@adameat adameat closed this Aug 21, 2025
Copilot AI changed the title [WIP] сделай ишью на английском про то чтоб решить проблему чтоб обработчик render вызывался только когда в capabilities вернулся признак что GraphShardExists=... fix: prevent render API calls when GraphShardExists=false Aug 21, 2025
Copilot AI requested a review from adameat August 21, 2025 10:32
Copilot finished work on behalf of adameat August 21, 2025 10: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