Skip to content

Commit

Permalink
FIX error logging in repo delete
Browse files Browse the repository at this point in the history
  • Loading branch information
wabscale committed Feb 6, 2022
1 parent 134f69a commit 5ed30c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/anubis/github/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,18 @@ def delete_assignment_repo(user: User, assignment: Assignment, commit: bool = Tr
Submission.assignment_repo_id == repo.id,
).all()
submission_ids = list(map(lambda x: x.id, submissions))
logger.info(f'Deleting submissions len = {len(submission_ids)}')

# Go through all the submissions, deleting builds
# and tests as we go
logger.info(f'Deleting submission builds')
SubmissionBuild.query.filter(SubmissionBuild.submission_id.in_(submission_ids)).delete()

logger.info(f'Deleting submission results')
SubmissionTestResult.query.filter(SubmissionTestResult.submission_id.in_(submission_ids)).delete()

# Delete submissions themselves
logger.info(f'Deleting submissions')
Submission.query.filter(
Submission.id.in_(submission_ids),
).delete()
Expand All @@ -161,6 +166,7 @@ def delete_assignment_repo(user: User, assignment: Assignment, commit: bool = Tr
github_org, repo_name = parse("https://github.com/{}/{}", repo.repo_url)

# Delete the repo
logger.info(f'Deleting assignment repo db record')
AssignmentRepo.query.filter(AssignmentRepo.id == repo.id).delete(synchronize_session=False)

if commit:
Expand All @@ -170,7 +176,7 @@ def delete_assignment_repo(user: User, assignment: Assignment, commit: bool = Tr
try:
# Make the github api call to delete the repo on github
r = github_rest(f"/repos/{github_org}/{repo_name}", method="delete")
logger.error(r)
logger.info(f'successfully deleted repo {r}')
except Exception as e:
logger.error(traceback.format_exc())
logger.error(f"Failed to delete repo {e}")
Expand Down

0 comments on commit 5ed30c7

Please sign in to comment.