Skip to content

Commit

Permalink
Fix problems without accepts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlougach committed Apr 17, 2024
1 parent 901f174 commit 4dd9601
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
9 changes: 7 additions & 2 deletions code_analyzer/githomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def initCDS( self ):
#self.http.disable_ssl_certificate_validation=True

r = self.http_session.get("%s/%s/teams" % (self.CDSRoot, contest_id))
r.raise_for_status()
teamData = r.json()
startTime = time.strftime( "%a, %d %b %Y %H:%M:%S GMT", time.gmtime(0) )

Expand Down Expand Up @@ -255,7 +256,9 @@ def pullBackupsCDS( self ):
print(f'Unable to fetch backups for team {backup.team}{backup.path}. The team is skipped')
continue

if response.status_code == requests.codes.ok:
if response.status_code == requests.codes.ok and not response.content:
print("Skipping because backup is empty file")
elif response.status_code == requests.codes.ok and response.content:
sys.stdout.write("updated, commit to git... ")

backup.modTime = response.headers["last-modified"]
Expand All @@ -270,7 +273,9 @@ def pullBackupsCDS( self ):
shutil.rmtree( backupDir )
os.makedirs( backupDir )
try:
subprocess.call( [ "unzip", "-q", f.name, "-x",".git","-x",".git/*", "-d", backupDir ] )
retcode = subprocess.call( [ "unzip", "-q", f.name, "-x",".git","-x",".git/*", "-d", backupDir ] )
if retcode != 0:
raise RuntimeError()
except:
print(f"Failed to unzip {f.name} for {backupDir}")
os.unlink( f.name )
Expand Down
2 changes: 1 addition & 1 deletion misc_scripts/reset_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
--------------------------------------------------------
TRUNCATING ALL THE RELEVANT TABLES
<?php
$to_truncate = array('entries', 'submissions', 'teams', 'persons', 'team_persons', 'problems', 'team_regions');
$to_truncate = array('contests', 'entries', 'submissions', 'teams', 'persons', 'team_persons', 'problems', 'team_regions');
foreach ($to_truncate as $table) {
$sql = "DELETE FROM $table;\n";
print("CLEARING TABLE $table;\n");
Expand Down
24 changes: 14 additions & 10 deletions www/problem.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,24 @@ function PieChart(target, problem_id) {


#########################################
$result = mysqli_query($db, "select distinct team_id as team_id from submissions "
. " where problem_id = '$problem_id' and contest_time = $first_submission_time order by team_id");
$first_teams_to_submit = array();
while ($row = mysqli_fetch_assoc($result)) {
$first_teams_to_submit[] = sprintf("<a href='team.php?team_id=%d'>%d</a>", $row['team_id'], $row['team_id']);
if ($first_submission_time) {
$result = mysqli_query($db, "select distinct team_id as team_id from submissions "
. " where problem_id = '$problem_id' and contest_time = $first_submission_time order by team_id");
$first_teams_to_submit = array();
while ($row = mysqli_fetch_assoc($result)) {
$first_teams_to_submit[] = sprintf("<a href='team.php?team_id=%d'>%d</a>", $row['team_id'], $row['team_id']);
}
}
$first_teams_to_submit = $first_teams_to_submit ? sprintf("(Team %s)", implode(", ", $first_teams_to_submit)) : "";

#########################################
$result = mysqli_query($db, "select distinct team_id as team_id from submissions "
. " where problem_id = '$problem_id' and result = 'AC' and contest_time = $first_solution_time order by team_id");
$first_teams_to_solve = array();
while ($row = mysqli_fetch_assoc($result)) {
$first_teams_to_solve[] = sprintf("<a href='team.php?team_id=%d'>%d</a>", $row['team_id'], $row['team_id']);
if ($first_solution_time) {
$result = mysqli_query($db, "select distinct team_id as team_id from submissions "
. " where problem_id = '$problem_id' and result = 'AC' and contest_time = $first_solution_time order by team_id");
$first_teams_to_solve = array();
while ($row = mysqli_fetch_assoc($result)) {
$first_teams_to_solve[] = sprintf("<a href='team.php?team_id=%d'>%d</a>", $row['team_id'], $row['team_id']);
}
}
$first_teams_to_solve = $first_teams_to_solve ? sprintf("(Team %s)", implode(", ", $first_teams_to_solve)) : "";

Expand Down

0 comments on commit 4dd9601

Please sign in to comment.