@@ -51,25 +51,60 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
51
51
useMergedProblemMap ( ) . data ?? new Map < ProblemId , MergedProblem > ( ) ;
52
52
const userPointCountMap = getUserPointCounts ( mergedProblemMap , submissions ) ;
53
53
const totalCount = getTotalCount ( mergedProblemMap ) ;
54
+ const totalCountBy100 = totalCount . reduce (
55
+ (
56
+ ret : { point : number ; count : number } [ ] ,
57
+ current : { point : number ; count : number }
58
+ ) => {
59
+ const roundedPoint = Math . floor ( current . point / 100 ) * 100 ;
60
+ const prev = ret . find ( ( entry ) => entry . point === roundedPoint ) ;
61
+ if ( prev ) {
62
+ prev . count += current . count ;
63
+ } else {
64
+ ret . push ( { point : roundedPoint , count : current . count } ) ;
65
+ }
66
+ return ret ;
67
+ } ,
68
+ [ ]
69
+ ) ;
70
+
71
+ const getUserPointCountInArea = (
72
+ countByPoint : Map < number | null | undefined , number > ,
73
+ pointStart : number ,
74
+ pointEnd : number
75
+ ) => {
76
+ let ret = 0 ;
77
+ for ( let i = 0 ; i < totalCount . length ; i ++ ) {
78
+ if ( totalCount [ i ] . point < pointStart ) {
79
+ continue ;
80
+ }
81
+ if ( totalCount [ i ] . point >= pointEnd ) {
82
+ break ;
83
+ }
84
+ ret += countByPoint . get ( totalCount [ i ] . point ) ?? 0 ;
85
+ }
86
+ return ret ;
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 >
@@ -78,16 +113,17 @@ export const SmallTable: React.FC<Props> = ({ submissions, setFilterFunc }) => {
78
113
{ userPointCountMap . 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 = {
85
- countByPoint . get ( point ) === count
120
+ getUserPointCountInArea ( countByPoint , point , point + 100 ) ===
121
+ count
86
122
? TableColor . Success
87
123
: TableColor . None
88
124
}
89
125
>
90
- { countByPoint . get ( point ) ?? 0 }
126
+ { getUserPointCountInArea ( countByPoint , point , point + 100 ) ?? 0 }
91
127
</ td >
92
128
) ) }
93
129
</ tr >
0 commit comments