mirror of
https://github.com/hanzonet/explore.git
synced 2026-10-30 18:16:57 +00:00
* Unify stats across relevant pages * add op stats to tx page and change stats titles * demo config * aboba or cat fix * chart tooltip fix * tests * revert config
29 lines
911 B
TypeScript
29 lines
911 B
TypeScript
import type { TChainIndicator } from '../types';
|
|
import type * as stats from '@blockscout/stats-types';
|
|
import type { HomeStats } from 'types/api/stats';
|
|
|
|
import config from 'configs/app';
|
|
|
|
export default function getIndicatorValues(indicator: TChainIndicator, statsData?: stats.MainPageStats, statsApiData?: HomeStats) {
|
|
const value = (() => {
|
|
if (config.features.stats.isEnabled && indicator?.valueMicroservice && statsData) {
|
|
return indicator.valueMicroservice(statsData);
|
|
}
|
|
|
|
if (statsApiData) {
|
|
return indicator?.value(statsApiData);
|
|
}
|
|
|
|
return 'N/A';
|
|
})();
|
|
|
|
// we have diffs only for coin and second coin price charts that get data from stats api
|
|
// so we don't check microservice data here, but may require to add it in the future
|
|
const valueDiff = indicator?.valueDiff ? indicator.valueDiff(statsApiData) : undefined;
|
|
|
|
return {
|
|
value,
|
|
valueDiff,
|
|
};
|
|
}
|