Skip to content

Commit

Permalink
add judge UID for judgetask
Browse files Browse the repository at this point in the history
  • Loading branch information
Zztrans committed Sep 22, 2024
1 parent c11ec9b commit 18a971a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion judger/src/agent/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ impl PlatformClient {

pub async fn report_judge_task(
&self,
judge_uid: &str,
stream_id: &str,
verdict: JudgeVerdict,
) -> Result<(), anyhow::Error> {
report_task(&self.client, stream_id, verdict).await
report_task(&self.client, judge_uid, stream_id, verdict).await
}
}

Expand Down Expand Up @@ -163,6 +164,8 @@ async fn report_judge_result(

#[derive(Serialize)]
struct ReportJudgeTaskBody {
#[serde(rename = "judgeUID")]
judge_uid: String,
consumer: String,
#[serde(rename = "redisStreamID")]
redis_stream_id: String,
Expand All @@ -175,11 +178,13 @@ struct ReportJudgeTaskResponse {

async fn report_task(
client: &HttpClient,
judge_uid: &str,
stream_id: &str,
verdict: JudgeVerdict,
) -> Result<(), anyhow::Error> {
let report_url = "api/v1/judge/task/report";
let body = ReportJudgeTaskBody {
judge_uid: judge_uid.to_owned(),
consumer: "".to_string(),
redis_stream_id: stream_id.to_owned(),
verdict,
Expand Down
8 changes: 6 additions & 2 deletions judger/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ impl JudgeWorker {
verdict = JudgeVerdict::CompileError;
}
let _ = platform_client
.report_judge_task(&task.redis_stream_id.clone(), verdict)
.report_judge_task(
&task.judge_uid,
&task.redis_stream_id.clone(),
verdict,
)
.await
.map_err(|e| {
log::debug!("Failed to report judge task: {:?}", e);
Expand Down Expand Up @@ -149,7 +153,7 @@ impl JudgeWorker {
}

let _ = platform_client
.report_judge_task(&task.redis_stream_id.clone(), verdict)
.report_judge_task(&task.judge_uid, &task.redis_stream_id.clone(), verdict)
.await
.map_err(|e| {
log::debug!("Failed to report judge task: {:?}", e);
Expand Down

0 comments on commit 18a971a

Please sign in to comment.