Skip to content

Commit

Permalink
Implement "first solved at" in SubmitStats
Browse files Browse the repository at this point in the history
This is disabled by default because I haven't yet figured out a nice way
of showing team names inside beamer frames (without using \verb, which
forces every contest to use [fragile] in its beamer setup).

See issue #9
  • Loading branch information
hex539 committed Jan 2, 2020
1 parent 008ecb1 commit 31a2ac0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 16 additions & 1 deletion analysis/src/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,29 @@ private static void draw(
}

if (printSolveStats) {
System.out.printf("\\providecommand{\\printfirstsolve}[2]{Solved at #2 by \\textbf{#1}}\n");
System.out.printf("\\providecommand{\\notsolved}{Not solved}\n");
fullModel.getProblemsModel().getProblems().stream().forEach(problem -> {
final SubmitStats stats = statsByProblem.get(problem.getId()).crop();
System.out.printf(
"\\newcommand{\\solvestats%s}{\\printsolvestats{%d}{%d}{%d}}\n",
"\\providecommand{\\solvestats%s}{\\printsolvestats{%d}{%d}{%d}}\n",
problem.getLabel(),
stats.totalAttempts,
stats.totalAccepted,
stats.totalPending);
if (stats.firstSolveAt != -1) {
System.out.printf(
"% \\providecommand{\\firstsolve%s}{\\printfirstsolve{%s}{%02d:%02d:%02d}}\n",
problem.getLabel(),
stats.firstSolveBy.getName(),
(stats.firstSolveAt / 3600),
(stats.firstSolveAt / 60) % 60,
(stats.firstSolveAt) % 60);
} else {
System.out.printf(
"\\providecommand{\\firstsolve%s}{\\notsolved}\n",
problem.getLabel());
}
});
}

Expand Down
7 changes: 7 additions & 0 deletions analysis/src/SubmitStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class SubmitStats {
private static final long SECONDS_PER_BAR = (60 * 5) / 2;
private static final long MAX_SUBMISSIONS = 20;

long firstSolveAt = -1;
Team firstSolveBy = null;

int totalAttempts = 0;
int totalAccepted = 0;
int totalPending = 0;
Expand Down Expand Up @@ -73,6 +76,10 @@ public SubmitStats add(Submission submission, Judgement judgement, ScoreboardMod
if (grouping == accepted) {
add(teamsAccepted, team, submission);
totalAccepted += 1;
if (firstSolveAt == -1 || submission.getContestTime().getSeconds() < firstSolveAt) {
firstSolveAt = submission.getContestTime().getSeconds();
firstSolveBy = team;
}
}
if (grouping == pending) {
add(teamsPending, team, submission);
Expand Down

0 comments on commit 31a2ac0

Please sign in to comment.