-
Notifications
You must be signed in to change notification settings - Fork 534
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
base: main
Are you sure you want to change the base?
Conversation
return 'N/A'; | ||
})(); | ||
|
||
// we have diffs only for coin adn second coin price charts that get data from stats api |
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.
// 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; |
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.
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?
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, | ||
}, | ||
}); |
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.
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.
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