@@ -50,35 +50,70 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
50
50
const mergedProblemMap =
51
51
useMergedProblemMap ( ) . data ?? new Map < ProblemId , MergedProblem > ( ) ;
52
52
const userPointCountMap = getUserPointCounts ( mergedProblemMap , submissions ) ;
53
+ const userPointCountMapBy100 = userPointCountMap . map (
54
+ ( { userId, countByPoint } ) => {
55
+ const roundedCountByPoint = new Map < number , number > ( ) ;
56
+ countByPoint . forEach ( ( count , point ) => {
57
+ if ( point === null || point === undefined ) {
58
+ return ;
59
+ }
60
+ const roundedPoint = Math . floor ( point / 100 ) * 100 ;
61
+ const prev = roundedCountByPoint . get ( roundedPoint ) ;
62
+ if ( prev ) {
63
+ roundedCountByPoint . set ( roundedPoint , prev + count ) ;
64
+ } else {
65
+ roundedCountByPoint . set ( roundedPoint , count ) ;
66
+ }
67
+ } ) ;
68
+ return { userId, countByPoint : roundedCountByPoint } ;
69
+ }
70
+ ) ;
53
71
const totalCount = getTotalCount ( mergedProblemMap ) ;
72
+ const totalCountBy100 = totalCount . reduce (
73
+ (
74
+ ret : { point : number ; count : number } [ ] ,
75
+ current : { point : number ; count : number }
76
+ ) => {
77
+ const roundedPoint = Math . floor ( current . point / 100 ) * 100 ;
78
+ const prev = ret . find ( ( entry ) => entry . point === roundedPoint ) ;
79
+ if ( prev ) {
80
+ prev . count += current . count ;
81
+ } else {
82
+ ret . push ( { point : roundedPoint , count : current . count } ) ;
83
+ }
84
+ return ret ;
85
+ } ,
86
+ [ ]
87
+ ) ;
88
+
54
89
return (
55
90
< Table striped bordered hover responsive >
56
91
< thead >
57
92
< tr >
58
93
< th > Point</ th >
59
- { totalCount . map ( ( { point } ) => (
94
+ { totalCountBy100 . map ( ( { point } ) => (
60
95
< th key = { point } >
61
96
< a
62
97
href = { window . location . hash }
63
98
onClick = { ( ) : void => setFilterFunc ( point ) }
64
99
>
65
- { point }
100
+ { ` ${ point } - ` }
66
101
</ a >
67
102
</ th >
68
103
) ) }
69
104
</ tr >
70
105
< tr >
71
106
< th > Total</ th >
72
- { totalCount . map ( ( { point, count } ) => (
107
+ { totalCountBy100 . map ( ( { point, count } ) => (
73
108
< th key = { point } > { count } </ th >
74
109
) ) }
75
110
</ tr >
76
111
</ thead >
77
112
< tbody >
78
- { userPointCountMap . map ( ( { userId, countByPoint } ) => (
113
+ { userPointCountMapBy100 . map ( ( { userId, countByPoint } ) => (
79
114
< tr key = { userId } >
80
115
< td > { userId } </ td >
81
- { totalCount . map ( ( { point, count } ) => (
116
+ { totalCountBy100 . map ( ( { point, count } ) => (
82
117
< td
83
118
key = { point }
84
119
className = {
0 commit comments