From 4cd3b242c0bcf093687fc441d0e69e97a1366cab Mon Sep 17 00:00:00 2001 From: Tim deBoer Date: Wed, 2 Apr 2025 16:03:52 -0400 Subject: [PATCH] handle draft vs current spec On the main branch the CDS has moved up to the draft spec, but for NAC and Baku we will be running on the 2023_06 spec and there's no target to finalize the current draft. In order to safely run these contests and release the CDS in the interim, the default should be the 2023_06 spec. This PR: - Switches the default spec back to 2023_06. - Changes the system property to 'ICPC_CONTEST_API=draft' in order to use the new/draft spec - the idea being that we always support the current released spec with an option to enable the new draft. - Adds support to the /access endpoint to return the correct spec version. - Adds a 'contest-api' property to the cdsConfig to make it easy to switch between specs, e.g. `= 0) { - if (is202306) { - pw.write(",\"time\":" + ContestUtil.getTime(s.getLastSolutionTime()) + "},\n"); - } else { + if (isDraftSpec) { pw.write(",\"time\":\"" + RelativeTime.format(s.getLastSolutionTime()) + "\"},\n"); + } else { + pw.write(",\"time\":" + ContestUtil.getTime(s.getLastSolutionTime()) + "},\n"); } } else pw.write("},\n"); @@ -101,10 +101,10 @@ public static void writeScoreboard(PrintWriter pw, IContest contest) { pw.write(",\"first_to_solve\":true"); } else if (ScoreboardType.SCORE.equals(scoreboardType)) pw.write("\"score\":" + round(r.getScore())); - if (is202306) { - pw.write(",\"time\":" + ContestUtil.getTime(r.getContestTime())); - } else { + if (isDraftSpec) { pw.write(",\"time\":\"" + RelativeTime.format(r.getContestTime()) + "\""); + } else { + pw.write(",\"time\":" + ContestUtil.getTime(r.getContestTime())); } } else pw.write("\"solved\":false"); diff --git a/ContestModel/src/org/icpc/tools/contest/model/internal/Info.java b/ContestModel/src/org/icpc/tools/contest/model/internal/Info.java index 53d989fc39..0f95a50c80 100644 --- a/ContestModel/src/org/icpc/tools/contest/model/internal/Info.java +++ b/ContestModel/src/org/icpc/tools/contest/model/internal/Info.java @@ -14,7 +14,7 @@ import org.icpc.tools.contest.model.feed.Timestamp; public class Info extends ContestObject implements IInfo { - private static final boolean is202306 = "2023-06".equals(System.getProperty("ICPC_CONTEST_API")); + private static final boolean isDraftSpec = "draft".equals(System.getProperty("ICPC_CONTEST_API")); private static final String NAME = "name"; private static final String FORMAL_NAME = "formal_name"; @@ -341,10 +341,10 @@ else if (ScoreboardType.SCORE.equals(scoreboardType)) props.addLiteralString(SCOREBOARD_THAW_TIME, Timestamp.format(thawTime.longValue())); if (penalty != null) { - if (is202306) - props.addInt(PENALTY_TIME, (int) (penalty.longValue() / (60 * 1000L))); - else + if (isDraftSpec) props.addLiteralString(PENALTY_TIME, RelativeTime.format(penalty)); + else + props.addInt(PENALTY_TIME, (int) (penalty.longValue() / (60 * 1000L))); } if (!Double.isNaN(timeMultiplier))