Skip to content

Commit 80912c4

Browse files
committedSep 18, 2024··
chore: better naming for clarity
1 parent 9da8250 commit 80912c4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed
 

‎web/src/hooks/queries/useHomePageExtraStats.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ import { averageBlockTimeInSeconds } from "consts/averageBlockTimeInSeconds";
1313

1414
type Court = HomePageBlockQuery["courts"][number];
1515

16-
const getCourtWithMaxDifference = (initialCourts: Court[], endCourts: Court[]): Court => {
17-
const diffs = initialCourts.map((court, idx) => {
18-
return Number(endCourts[idx].numberDisputes) - Number(court.numberDisputes);
16+
const getCourtWithMaxDifference = (lastWeekCourts: Court[], currentCourts: Court[]): Court => {
17+
const diffs = lastWeekCourts.map((court, idx) => {
18+
return Number(currentCourts[idx].numberDisputes) - Number(court.numberDisputes);
1919
});
2020

2121
const maxDiffCourtId = diffs.reduce((a, b) => (a > b ? a : b));
2222

23-
return initialCourts[diffs.indexOf(maxDiffCourtId)];
23+
return lastWeekCourts[diffs.indexOf(maxDiffCourtId)];
2424
};
2525

26-
const getCourtWithMaxReward = (courts: Court[]): Court => {
27-
return courts.reduce((a, b) => (Number(a.feeForJuror) > Number(b.feeForJuror) ? a : b));
26+
const getCourtWithMaxDrawingChance = (currentCourts: Court[]): Court => {
27+
return currentCourts.reduce((a, b) => (Number(a.stake) > Number(b.feeForJuror) ? b : a));
2828
};
2929

30-
const getCourtWithMaxChance = (courts: Court[]): Court => {
31-
return courts.reduce((a, b) => (Number(a.stake) > Number(b.feeForJuror) ? b : a));
30+
const getCourtWithMaxRewardChance = (currentCourts: Court[]): Court => {
31+
return currentCourts.reduce((a, b) => (Number(a.feeForJuror) > Number(b.feeForJuror) ? a : b));
3232
};
3333

3434
export interface HomePageExtraStatsType {
@@ -51,20 +51,20 @@ export const useHomePageExtraStats = (): HomePageExtraStatsType => {
5151

5252
const { data: relData } = useHomePageBlockQuery(oneWeekAgoBlockNumber!);
5353

54-
const HighestDrawingChance = useMemo(() => {
55-
return data ? getCourtWithMaxChance(data.courts).name ?? null : null;
56-
}, [data]);
57-
58-
const HighestRewardChance = useMemo(() => {
59-
return data ? getCourtWithMaxReward(data.courts).name ?? null : null;
60-
}, [data]);
61-
6254
const MostActiveCourt = useMemo(() => {
6355
if (isUndefined(relData) || isUndefined(data)) {
6456
return null;
6557
}
6658
return getCourtWithMaxDifference(relData.courts, data.courts).name ?? null;
6759
}, [relData, data]);
6860

61+
const HighestDrawingChance = useMemo(() => {
62+
return data ? getCourtWithMaxDrawingChance(data.courts).name ?? null : null;
63+
}, [data]);
64+
65+
const HighestRewardChance = useMemo(() => {
66+
return data ? getCourtWithMaxRewardChance(data.courts).name ?? null : null;
67+
}, [data]);
68+
6969
return { MostActiveCourt, HighestDrawingChance, HighestRewardChance };
7070
};

‎web/src/pages/Home/CourtOverview/ExtraStats.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const ExtraStats = () => {
4343
const data = useHomePageExtraStats();
4444
return (
4545
<StyledCard>
46-
<ExtraStatsDisplay title="Activity (Last 7 days)" icon={LawBalance} />
46+
<ExtraStatsDisplay title="Activity (Last 7 days)" text="" icon={LawBalance} />
4747
{stats.map(({ title, getText, icon }, i) => {
4848
return <ExtraStatsDisplay key={i} {...{ title, icon }} text={getText(data)} />;
4949
})}

0 commit comments

Comments
 (0)
Please sign in to comment.