mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
chore: 🔧 debugging
This commit is contained in:
parent
42c9c6d5f3
commit
70bb14e509
7 changed files with 51 additions and 14 deletions
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue