diff --git a/pages/stats.tsx b/pages/stats.tsx index 7a25ebf5..825aa83c 100644 --- a/pages/stats.tsx +++ b/pages/stats.tsx @@ -8,9 +8,6 @@ import { StatResume } from 'src/views/stats/StatResume'; import { StatsProvider } from 'src/views/stats/context'; import { NextPageContext } from 'next'; import { getProps } from 'src/utils/ssr'; -import { GET_FEE_HEALTH } from 'src/graphql/queries/getFeeHealth'; -import { GET_VOLUME_HEALTH } from 'src/graphql/queries/getVolumeHealth'; -import { GET_TIME_HEALTH } from 'src/graphql/queries/getTimeHealth'; import { GET_NODE_INFO } from 'src/graphql/queries/getNodeInfo'; import { SingleLine } from '../src/components/generic/Styled'; @@ -45,10 +42,5 @@ const Wrapped = () => ( export default Wrapped; export async function getServerSideProps(context: NextPageContext) { - return await getProps(context, [ - GET_FEE_HEALTH, - GET_VOLUME_HEALTH, - GET_TIME_HEALTH, - GET_NODE_INFO, - ]); + return await getProps(context, [GET_NODE_INFO]); } diff --git a/server/schema/health/resolvers/getFeeHealth.ts b/server/schema/health/resolvers/getFeeHealth.ts index 94c90a41..90e5e89f 100644 --- a/server/schema/health/resolvers/getFeeHealth.ts +++ b/server/schema/health/resolvers/getFeeHealth.ts @@ -101,6 +101,13 @@ export default async (_: undefined, params: any, context: ContextType) => { baseOver: myBaseScore.over, }; + Object.entries(mySide).forEach(entry => { + const [key, value] = entry; + if (isNaN(value as number)) { + logger.debug(`${key} is NAN (getFeeHealth)`); + } + }); + const partnerSide = { score: partnerScore, rate: channel.partnerFeeRate, @@ -111,6 +118,13 @@ export default async (_: undefined, params: any, context: ContextType) => { baseOver: true, }; + Object.entries(partnerSide).forEach(entry => { + const [key, value] = entry; + if (isNaN(value as number)) { + logger.debug(`${key} is NAN (getFeeHealth)`); + } + }); + return { id: channel.id, partnerSide, diff --git a/server/schema/health/resolvers/getTimeHealth.ts b/server/schema/health/resolvers/getTimeHealth.ts index d1c8a372..4d4902ca 100644 --- a/server/schema/health/resolvers/getTimeHealth.ts +++ b/server/schema/health/resolvers/getTimeHealth.ts @@ -3,6 +3,7 @@ import { requestLimiter } from 'server/helpers/rateLimiter'; import { to } from 'server/helpers/async'; import { ContextType } from 'server/types/apiTypes'; import { GetChannelsType } from 'server/types/ln-service.types'; +import { logger } from 'server/helpers/logger'; import { getAverage } from '../helpers'; const halfMonthInMilliSeconds = 1296000000; @@ -35,6 +36,17 @@ export default async (_: undefined, __: any, context: ContextType) => { const percentOnline = time_online / (time_online + time_offline); + if (isNaN(percentOnline)) { + logger.debug('percentOnline is NAN'); + } + + Object.entries(defaultProps).forEach(entry => { + const [key, value] = entry; + if (isNaN(value as number)) { + logger.debug(`${key} is NAN (getTimeHealth)`); + } + }); + return { score: Math.round(percentOnline * 100), ...defaultProps, diff --git a/server/schema/health/resolvers/getVolumeHealth.ts b/server/schema/health/resolvers/getVolumeHealth.ts index 300977b4..b7bdde06 100644 --- a/server/schema/health/resolvers/getVolumeHealth.ts +++ b/server/schema/health/resolvers/getVolumeHealth.ts @@ -7,6 +7,7 @@ import { GetChannelsType, GetForwardsType, } from 'server/types/ln-service.types'; +import { logger } from 'server/helpers/logger'; import { getChannelVolume, getChannelIdInfo, getAverage } from '../helpers'; const monthInBlocks = 4380; @@ -43,12 +44,21 @@ export default async (_: undefined, params: any, context: ContextType) => { monthInBlocks ); - return { + const params = { id: channel.id, volume: tokens, volumeNormalized: Math.round(tokens / age) || 0, publicKey: channel.partner_public_key, }; + + Object.entries(params).forEach(entry => { + const [key, value] = entry; + if (isNaN(value as number)) { + logger.debug(`${key} is NAN (getVolumeHealth)`); + } + }); + + return params; }) .filter(Boolean); @@ -60,13 +70,22 @@ export default async (_: undefined, params: any, context: ContextType) => { const diff = (channel.volumeNormalized - average) / average || -1; const score = Math.round((diff + 1) * 100); - return { + const params = { id: channel.id, score, volumeNormalized: channel.volumeNormalized, averageVolumeNormalized: average, partner: { publicKey: channel.publicKey, lnd }, }; + + Object.entries(params).forEach(entry => { + const [key, value] = entry; + if (isNaN(value as number)) { + logger.debug(`${key} is NAN (getVolumeHealth)`); + } + }); + + return params; }) .filter(Boolean); diff --git a/src/views/stats/FeeStats.tsx b/src/views/stats/FeeStats.tsx index 01cbef04..a22e5154 100644 --- a/src/views/stats/FeeStats.tsx +++ b/src/views/stats/FeeStats.tsx @@ -84,7 +84,7 @@ export const FeeStats = () => { const [openTwo, openTwoSet] = React.useState(0); const dispatch = useStatsDispatch(); - const { data, loading } = useGetFeeHealthQuery(); + const { data, loading } = useGetFeeHealthQuery({ ssr: false }); React.useEffect(() => { if (data && data.getFeeHealth) { diff --git a/src/views/stats/FlowStats.tsx b/src/views/stats/FlowStats.tsx index 5bf381f8..bc331052 100644 --- a/src/views/stats/FlowStats.tsx +++ b/src/views/stats/FlowStats.tsx @@ -64,7 +64,7 @@ const VolumeStatCard = ({ export const VolumeStats = () => { const [open, openSet] = React.useState(0); const dispatch = useStatsDispatch(); - const { data, loading } = useGetVolumeHealthQuery(); + const { data, loading } = useGetVolumeHealthQuery({ ssr: false }); React.useEffect(() => { if (data && data.getVolumeHealth) { diff --git a/src/views/stats/TimeStats.tsx b/src/views/stats/TimeStats.tsx index f8ee6fad..879dae47 100644 --- a/src/views/stats/TimeStats.tsx +++ b/src/views/stats/TimeStats.tsx @@ -67,7 +67,7 @@ const TimeStatCard = ({ channel, open, openSet, index }: TimeStatCardProps) => { export const TimeStats = () => { const [open, openSet] = React.useState(0); const dispatch = useStatsDispatch(); - const { data, loading } = useGetTimeHealthQuery(); + const { data, loading } = useGetTimeHealthQuery({ ssr: false }); React.useEffect(() => { if (data && data.getTimeHealth) {