Skip to content

Commit

Permalink
Revert "chore: 🔧 debugging"
Browse files Browse the repository at this point in the history
This reverts commit 70bb14e.
  • Loading branch information
apotdevin committed Aug 31, 2020
1 parent 6972b25 commit af6d6ac
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 51 deletions.
10 changes: 9 additions & 1 deletion pages/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ 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';

Expand Down Expand Up @@ -42,5 +45,10 @@ const Wrapped = () => (
export default Wrapped;

export async function getServerSideProps(context: NextPageContext) {
return await getProps(context, [GET_NODE_INFO]);
return await getProps(context, [
GET_FEE_HEALTH,
GET_VOLUME_HEALTH,
GET_TIME_HEALTH,
GET_NODE_INFO,
]);
}
14 changes: 0 additions & 14 deletions server/schema/health/resolvers/getFeeHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ 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,
Expand All @@ -118,13 +111,6 @@ 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,
Expand Down
12 changes: 0 additions & 12 deletions server/schema/health/resolvers/getTimeHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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;
Expand Down Expand Up @@ -36,17 +35,6 @@ 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,
Expand Down
23 changes: 2 additions & 21 deletions server/schema/health/resolvers/getVolumeHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
GetChannelsType,
GetForwardsType,
} from 'server/types/ln-service.types';
import { logger } from 'server/helpers/logger';
import { getChannelVolume, getChannelIdInfo, getAverage } from '../helpers';

const monthInBlocks = 4380;
Expand Down Expand Up @@ -44,21 +43,12 @@ export default async (_: undefined, params: any, context: ContextType) => {
monthInBlocks
);

const params = {
return {
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);

Expand All @@ -70,22 +60,13 @@ export default async (_: undefined, params: any, context: ContextType) => {
const diff = (channel.volumeNormalized - average) / average || -1;
const score = Math.round((diff + 1) * 100);

const params = {
return {
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);

Expand Down
2 changes: 1 addition & 1 deletion src/views/stats/FeeStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const FeeStats = () => {
const [openTwo, openTwoSet] = React.useState(0);
const dispatch = useStatsDispatch();

const { data, loading } = useGetFeeHealthQuery({ ssr: false });
const { data, loading } = useGetFeeHealthQuery();

React.useEffect(() => {
if (data && data.getFeeHealth) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/stats/FlowStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const VolumeStatCard = ({
export const VolumeStats = () => {
const [open, openSet] = React.useState(0);
const dispatch = useStatsDispatch();
const { data, loading } = useGetVolumeHealthQuery({ ssr: false });
const { data, loading } = useGetVolumeHealthQuery();

React.useEffect(() => {
if (data && data.getVolumeHealth) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/stats/TimeStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({ ssr: false });
const { data, loading } = useGetTimeHealthQuery();

React.useEffect(() => {
if (data && data.getTimeHealth) {
Expand Down

0 comments on commit af6d6ac

Please sign in to comment.