Skip to content

Commit dedab98

Browse files
committed
♻️ Improve contest id comparison logic (#1807)
1 parent a481e46 commit dedab98

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/lib/utils/contest_table_provider.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ class ABCLatest20RoundsProvider extends ContestTableProviderBase {
117117
// 7 tasks per contest
118118
class 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.
143145
class 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,10 @@ class ABC212ToABC318Provider extends ContestTableProviderBase {
160164
}
161165
}
162166

167+
function parseContestRound(contestId: string, prefix: string): number {
168+
return parseInt(contestId.replace(prefix, ''), 10);
169+
}
170+
163171
// TODO: Add providers for other contest types if needs.
164172
export const contestTableProviders = {
165173
abcLatest20Rounds: new ABCLatest20RoundsProvider(ContestType.ABC),

0 commit comments

Comments
 (0)