Skip to content

Commit

Permalink
feat(be): add double depth field to admin get submission api (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimin9038 authored Sep 15, 2024
1 parent 4130f60 commit cdac2e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,13 @@ class TestCaseResult {

@ObjectType()
export class SubmissionDetail extends OmitType(Submission, [
'user',
'submissionResult',
'code',
'problem',
'contest',
'workbook',
'_count'
] as const) {
@Field(() => String)
code: string

@Field(() => [TestCaseResult])
testcaseResult: TestCaseResult[]

@Field(() => String, { nullable: true })
username: string | null
}
14 changes: 7 additions & 7 deletions apps/backend/apps/admin/src/submission/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ export class SubmissionService {
},
include: {
user: {
select: {
username: true
include: {
userProfile: true
}
},
problem: true,
contest: true,
submissionResult: true
}
})
Expand All @@ -103,14 +105,12 @@ export class SubmissionService {
})
results.sort((a, b) => a.problemTestcaseId - b.problemTestcaseId)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { submissionResult, user, ...submissionWithoutResultAndUser } =
submission
const { submissionResult, ...submissionWithoutResult } = submission

return {
...submissionWithoutResultAndUser,
...submissionWithoutResult,
code: code.map((snippet) => snippet.text).join('\n'),
testcaseResult: results,
username: submission.user?.username ?? null
testcaseResult: results
}
}
}
17 changes: 16 additions & 1 deletion collection/admin/Submission/Get Submission Detail/Succeed.bru
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ body:graphql {
createTime
updateTime
}
username
user {
id
studentId
userProfile {
realName
}
}
contest {
id
title
}
problem {
id
title

}
}
}

Expand Down

0 comments on commit cdac2e7

Please sign in to comment.