change audit response format

This commit is contained in:
Laura Abro
2025-04-24 19:41:37 -03:00
parent 1f5bd58e1d
commit 5da4b51cfc
2 changed files with 25 additions and 18 deletions

View File

@ -16,7 +16,10 @@ def audit_submission(round_number: int):
submission = data.get("submission")
if not submission:
return jsonify({"error": "Missing submission"}), 400
return (
jsonify({"success": False, "data": {"error": "Missing submission"}}),
400,
)
submission_round_number = submission.get("roundNumber")
task_id = submission.get("taskId")
@ -29,10 +32,16 @@ def audit_submission(round_number: int):
repo_owner = pr_url_parts[0]
repo_name = pr_url_parts[1]
except (IndexError, AttributeError):
return jsonify({"error": "Invalid PR URL format"}), 400
return (
jsonify({"success": False, "data": {"error": "Invalid PR URL format"}}),
400,
)
print(f"Repo owner: {repo_owner}, Repo name: {repo_name}")
if int(round_number) != submission_round_number:
return jsonify({"error": "Round number mismatch"}), 400
return (
jsonify({"success": False, "data": {"error": "Round number mismatch"}}),
400,
)
if (
not task_id
@ -41,7 +50,10 @@ def audit_submission(round_number: int):
or not repo_owner
or not repo_name
):
return jsonify({"error": "Missing submission data"}), 400
return (
jsonify({"success": False, "data": {"error": "Missing submission data"}}),
400,
)
is_valid = verify_pr_ownership(
pr_url=pr_url,
@ -51,11 +63,11 @@ def audit_submission(round_number: int):
)
if not is_valid:
return jsonify(False)
return jsonify({"success": True, "data": {"is_approved": False}}), 200
try:
is_approved = audit_repo(pr_url)
return jsonify(is_approved), 200
return jsonify({"success": True, "data": {"is_approved": is_approved}}), 200
except Exception as e:
logger.error(f"Error auditing PR: {str(e)}")
return jsonify(True), 200
return jsonify({"success": True, "data": {"is_approved": True}}), 200