change audit response format
This commit is contained in:
@ -16,7 +16,10 @@ def audit_submission(round_number: int):
|
|||||||
submission = data.get("submission")
|
submission = data.get("submission")
|
||||||
|
|
||||||
if not 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")
|
submission_round_number = submission.get("roundNumber")
|
||||||
task_id = submission.get("taskId")
|
task_id = submission.get("taskId")
|
||||||
@ -29,10 +32,16 @@ def audit_submission(round_number: int):
|
|||||||
repo_owner = pr_url_parts[0]
|
repo_owner = pr_url_parts[0]
|
||||||
repo_name = pr_url_parts[1]
|
repo_name = pr_url_parts[1]
|
||||||
except (IndexError, AttributeError):
|
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}")
|
print(f"Repo owner: {repo_owner}, Repo name: {repo_name}")
|
||||||
if int(round_number) != submission_round_number:
|
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 (
|
if (
|
||||||
not task_id
|
not task_id
|
||||||
@ -41,7 +50,10 @@ def audit_submission(round_number: int):
|
|||||||
or not repo_owner
|
or not repo_owner
|
||||||
or not repo_name
|
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(
|
is_valid = verify_pr_ownership(
|
||||||
pr_url=pr_url,
|
pr_url=pr_url,
|
||||||
@ -51,11 +63,11 @@ def audit_submission(round_number: int):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return jsonify(False)
|
return jsonify({"success": True, "data": {"is_approved": False}}), 200
|
||||||
|
|
||||||
try:
|
try:
|
||||||
is_approved = audit_repo(pr_url)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error auditing PR: {str(e)}")
|
logger.error(f"Error auditing PR: {str(e)}")
|
||||||
return jsonify(True), 200
|
return jsonify({"success": True, "data": {"is_approved": True}}), 200
|
||||||
|
@ -57,7 +57,7 @@ export async function audit(cid: string, roundNumber: number, submitterKey: stri
|
|||||||
console.log(`[AUDIT] Sending audit request for submitter: ${submitterKey}`);
|
console.log(`[AUDIT] Sending audit request for submitter: ${submitterKey}`);
|
||||||
console.log(`[AUDIT] Submission data being sent to audit:`, decodeResult);
|
console.log(`[AUDIT] Submission data being sent to audit:`, decodeResult);
|
||||||
|
|
||||||
const result = await orcaClient.podCall(`worker-audit/${roundNumber}`, {
|
const auditResult = await orcaClient.podCall(`worker-audit/${roundNumber}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -67,17 +67,12 @@ export async function audit(cid: string, roundNumber: number, submitterKey: stri
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`[AUDIT] Raw audit result:`, result);
|
if (auditResult.data.success) {
|
||||||
console.log(`[AUDIT] Audit result data type:`, typeof result.data);
|
console.log(`[AUDIT] ✅ Audit successful for ${submitterKey}`);
|
||||||
console.log(`[AUDIT] Audit result data value:`, result.data);
|
return auditResult.data.data.is_approved;
|
||||||
|
|
||||||
if (result.data === true) {
|
|
||||||
console.log(`[AUDIT] ✅ Audit passed for ${submitterKey}`);
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
console.log(`[AUDIT] ❌ Audit failed for ${submitterKey}`);
|
console.log(`[AUDIT] ❌ Audit could not be completed for ${submitterKey}`);
|
||||||
console.log(`[AUDIT] Failed audit result data:`, result.data);
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[AUDIT] Error auditing submission:", error);
|
console.error("[AUDIT] Error auditing submission:", error);
|
||||||
|
Reference in New Issue
Block a user