fix(2380): fixed block duration field to account for the new api format (#2423)
* fix(2380): fixed block duration field to account for the new api format * fix(2380): removed unneeded import * fix(2380): a little more hardened against duration being undefined and different environments returning different data * fix(2380): improved comment
This commit is contained in:
parent
98d01d7933
commit
f133200c7f
@ -1,3 +1,3 @@
|
|||||||
# App configuration variables
|
# App configuration variables
|
||||||
NX_VEGA_URL=https://api.stagnet3.vega.xyz/graphql
|
NX_VEGA_URL=https://api.stagnet3.vega.xyz/graphql
|
||||||
NX_VEGA_ENV=STAGNET3;
|
NX_VEGA_ENV=STAGNET3
|
||||||
|
@ -110,9 +110,30 @@ export const statsFields: { [key in keyof Stats]: StatFields[] } = {
|
|||||||
blockDuration: [
|
blockDuration: [
|
||||||
{
|
{
|
||||||
title: t('Block time'),
|
title: t('Block time'),
|
||||||
formatter: (duration: number) => (duration / 1000000000).toFixed(3),
|
formatter: (duration: string) => {
|
||||||
goodThreshold: (blockDuration: number) =>
|
const dp = 3;
|
||||||
blockDuration > 0 && blockDuration <= 2000000000,
|
if (duration?.includes('ms')) {
|
||||||
|
return (parseFloat(duration) / 1000).toFixed(dp).toString();
|
||||||
|
} else if (duration?.includes('s')) {
|
||||||
|
return parseFloat(duration).toFixed(dp).toString();
|
||||||
|
}
|
||||||
|
return duration
|
||||||
|
? (Number(duration) / 1000000000).toFixed(dp)
|
||||||
|
: undefined;
|
||||||
|
},
|
||||||
|
goodThreshold: (blockDuration: string) => {
|
||||||
|
if (blockDuration?.includes('ms')) {
|
||||||
|
// we only get ms from the api if duration is less than 1s, so this
|
||||||
|
// automatically passes
|
||||||
|
return true;
|
||||||
|
} else if (blockDuration?.includes('s')) {
|
||||||
|
return parseFloat(blockDuration) <= 2;
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
Number(blockDuration) > 0 && Number(blockDuration) <= 2000000000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
description: t('Seconds between the two most recent blocks'),
|
description: t('Seconds between the two most recent blocks'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user