@@ -50,35 +50,70 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
5050 const mergedProblemMap =
5151 useMergedProblemMap ( ) . data ?? new Map < ProblemId , MergedProblem > ( ) ;
5252 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+ ) ;
5371 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+
5489 return (
5590 < Table striped bordered hover responsive >
5691 < thead >
5792 < tr >
5893 < th > Point</ th >
59- { totalCount . map ( ( { point } ) => (
94+ { totalCountBy100 . map ( ( { point } ) => (
6095 < th key = { point } >
6196 < a
6297 href = { window . location . hash }
6398 onClick = { ( ) : void => setFilterFunc ( point ) }
6499 >
65- { point }
100+ { ` ${ point } - ` }
66101 </ a >
67102 </ th >
68103 ) ) }
69104 </ tr >
70105 < tr >
71106 < th > Total</ th >
72- { totalCount . map ( ( { point, count } ) => (
107+ { totalCountBy100 . map ( ( { point, count } ) => (
73108 < th key = { point } > { count } </ th >
74109 ) ) }
75110 </ tr >
76111 </ thead >
77112 < tbody >
78- { userPointCountMap . map ( ( { userId, countByPoint } ) => (
113+ { userPointCountMapBy100 . map ( ( { userId, countByPoint } ) => (
79114 < tr key = { userId } >
80115 < td > { userId } </ td >
81- { totalCount . map ( ( { point, count } ) => (
116+ { totalCountBy100 . map ( ( { point, count } ) => (
82117 < td
83118 key = { point }
84119 className = {
0 commit comments