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

Unify stats across relevant pages #2561

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Unify stats across relevant pages #2561

wants to merge 7 commits into from

Conversation

isstuev
Copy link
Collaborator

@isstuev isstuev commented Feb 7, 2025

Description and Related Issue(s)

resolves #2515

Proposed Changes

added daily_operational_txs option to NEXT_PUBLIC_HOMEPAGE_CHARTS and total_operational_txs to NEXT_PUBLIC_HOMEPAGE_STATS. Values can be used only if NEXT_PUBLIC_STATS_API_HOST is provided

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@isstuev isstuev changed the title Fe 2515 Unify stats across relevant pages Feb 10, 2025
@isstuev isstuev marked this pull request as ready for review February 10, 2025 17:28
@isstuev isstuev requested a review from tom2drum February 10, 2025 17:28
@github-actions github-actions bot added the enhancement New feature or request label Feb 10, 2025
@isstuev isstuev added the ENVs label Feb 10, 2025
return 'N/A';
})();

// we have diffs only for coin adn second coin price charts that get data from stats api
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// we have diffs only for coin adn second coin price charts that get data from stats api
// we have diffs only for coin and second coin price charts that get data from stats api

return null;
}

const isLoading = isStatsFeatureEnabled ? countersStatsQuery.isPlaceholderData : countersApiQuery.isPlaceholderData;

const contractsCount = isStatsFeatureEnabled ? countersStatsQuery.data?.total_contracts?.value : countersApiQuery.data?.smart_contracts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we always fall back to our regular API response, regardless of whether microservices data is enabled? For example, if there is an error in the response from the stats microservices, should we still display the information from our base API?

Comment on lines +15 to 27
const txsStatsQuery = useApiQuery('stats_transactions', {
queryOptions: {
enabled: isStatsFeatureEnabled,
placeholderData: isStatsFeatureEnabled ? TXS_STATS_MICROSERVICE : undefined,
},
});

const txsStatsApiQuery = useApiQuery('txs_stats', {
queryOptions: {
placeholderData: TXS_STATS,
enabled: !isStatsFeatureEnabled,
placeholderData: !isStatsFeatureEnabled ? TXS_STATS : undefined,
},
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

The same comment about fallback applies here.
I suggest abstracting these two hooks into a separate one that will orchestrate all requests and return the isLoading flag and data in a common format. This way, all necessary logic will be encapsulated in one place rather than be spreaded in the view component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ENVs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify stats across relevant pages
2 participants