@@ -13,22 +13,22 @@ import { averageBlockTimeInSeconds } from "consts/averageBlockTimeInSeconds";
1313
1414type 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
3434export 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} ;
0 commit comments