From c7f8d3c34077e3e9524e2b63f54d9fa78b4827bf Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 7 Mar 2024 17:26:10 +0800 Subject: [PATCH] migrate: hustoj: check if startAt is after endAt --- packages/migrate/scripts/hustoj.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/migrate/scripts/hustoj.ts b/packages/migrate/scripts/hustoj.ts index a5a615080..542a1e780 100644 --- a/packages/migrate/scripts/hustoj.ts +++ b/packages/migrate/scripts/hustoj.ts @@ -4,7 +4,7 @@ import path from 'path'; import mariadb from 'mariadb'; import TurndownService from 'turndown'; import { - _, buildContent, ContestModel, DomainModel, fs, MessageModel, noop, NotFoundError, ObjectId, postJudge, ProblemModel, + _, buildContent, ContestModel, DomainModel, fs, MessageModel, moment, noop, NotFoundError, ObjectId, postJudge, ProblemModel, RecordDoc, RecordModel, SolutionModel, STATUS, StorageModel, SystemModel, Time, UserModel, } from 'hydrooj'; @@ -251,9 +251,11 @@ hydrooj install https://hydro.ac/hydroac-client.zip files[file[2]] = await fs.readFile(path.join(uploadDir, file[1])); description = description.replace(`/upload/${file[1]}`, `file://${file[2]}`); } + // WHY you allow contest with end time BEFORE start time? WHY??? + const endAt = moment(tdoc.end_time).isSameOrBefore(tdoc.start_time) ? moment(tdoc.end_time).add(1, 'minute').toDate() : tdoc.end_time; const tid = await ContestModel.add( domainId, tdoc.title, tdoc.description || 'Description', - adminUids[0], contestType, tdoc.start_time, tdoc.end_time, pids, true, + adminUids[0], contestType, tdoc.start_time, endAt, pids, true, { _code: password }, ); tidMap[tdoc.contest_id] = tid.toHexString();