@@ -117,8 +117,10 @@ class ABCLatest20RoundsProvider extends ContestTableProviderBase {
117117// 7 tasks per contest
118118class ABC319OnwardsProvider extends ContestTableProviderBase {
119119 protected setFilterCondition ( ) : ( taskResult : TaskResult ) => boolean {
120- return ( taskResult : TaskResult ) =>
121- taskResult . contest_id >= 'abc319' && taskResult . contest_id <= 'abc999' ;
120+ return ( taskResult : TaskResult ) => {
121+ const contestRound = parseContestRound ( taskResult . contest_id , 'abc' ) ;
122+ return contestRound >= 319 ;
123+ } ;
122124 }
123125
124126 getMetadata ( ) : ContestTableMetaData {
@@ -142,8 +144,10 @@ class ABC319OnwardsProvider extends ContestTableProviderBase {
142144// Before and from ABC212 onwards, the number and tendency of tasks are very different.
143145class ABC212ToABC318Provider extends ContestTableProviderBase {
144146 protected setFilterCondition ( ) : ( taskResult : TaskResult ) => boolean {
145- return ( taskResult : TaskResult ) =>
146- taskResult . contest_id >= 'abc212' && taskResult . contest_id <= 'abc318' ;
147+ return ( taskResult : TaskResult ) => {
148+ const contestRound = parseContestRound ( taskResult . contest_id , 'abc' ) ;
149+ return contestRound >= 212 && contestRound <= 318 ;
150+ } ;
147151 }
148152
149153 getMetadata ( ) : ContestTableMetaData {
@@ -160,6 +164,17 @@ class ABC212ToABC318Provider extends ContestTableProviderBase {
160164 }
161165}
162166
167+ function parseContestRound ( contestId : string , prefix : string ) : number {
168+ const withoutPrefix = contestId . replace ( prefix , '' ) ;
169+
170+ // Verify the prefix was present and the remaining string is numeric
171+ if ( withoutPrefix === contestId || ! / ^ \d + $ / . test ( withoutPrefix ) ) {
172+ throw new Error ( `Invalid contest id has given: ${ contestId } ` ) ;
173+ }
174+
175+ return parseInt ( withoutPrefix , 10 ) ;
176+ }
177+
163178// TODO: Add providers for other contest types if needs.
164179export const contestTableProviders = {
165180 abcLatest20Rounds : new ABCLatest20RoundsProvider ( ContestType . ABC ) ,
0 commit comments