@@ -13,22 +13,22 @@ import { averageBlockTimeInSeconds } from "consts/averageBlockTimeInSeconds";
13
13
14
14
type Court = HomePageBlockQuery [ "courts" ] [ number ] ;
15
15
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 ) ;
19
19
} ) ;
20
20
21
21
const maxDiffCourtId = diffs . reduce ( ( a , b ) => ( a > b ? a : b ) ) ;
22
22
23
- return initialCourts [ diffs . indexOf ( maxDiffCourtId ) ] ;
23
+ return lastWeekCourts [ diffs . indexOf ( maxDiffCourtId ) ] ;
24
24
} ;
25
25
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 ) ) ;
28
28
} ;
29
29
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 ) ) ;
32
32
} ;
33
33
34
34
export interface HomePageExtraStatsType {
@@ -51,20 +51,20 @@ export const useHomePageExtraStats = (): HomePageExtraStatsType => {
51
51
52
52
const { data : relData } = useHomePageBlockQuery ( oneWeekAgoBlockNumber ! ) ;
53
53
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
-
62
54
const MostActiveCourt = useMemo ( ( ) => {
63
55
if ( isUndefined ( relData ) || isUndefined ( data ) ) {
64
56
return null ;
65
57
}
66
58
return getCourtWithMaxDifference ( relData . courts , data . courts ) . name ?? null ;
67
59
} , [ relData , data ] ) ;
68
60
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
+
69
69
return { MostActiveCourt, HighestDrawingChance, HighestRewardChance } ;
70
70
} ;
0 commit comments