#539 Code Review of Interview and Candidate Service
Perform a code review:
@Component
class InterviewService(
private val scoreRepository: ScoreRepository,
private val transactionTemplate: TransactionTemplate,
private val interviewScoreMLService: InterviewScoreMLService,
) {
private val objectMapper = ObjectMapper()
/**
* The method calculates how many points the candidate earned,
* saves the result to the database, and sends a callback to an external service
*/
fun process(c: Candidate) {
transactionTemplate.executeWithoutResult {
val s: Score = interviewScoreMLService.compute(c)
val request: Mono<ResponseEntity<Void>> = WebClient.create()
.post()
.body(BodyInserts.fromValue(objectMapper.writeValueAsString(c.name to s)))
.retrieve()
.toBodilessEntity()
scoreRepository.saveScore(s)
}
}
}
data class Candidate(
val name: String,
val exercisesSolvedId: List<Int>,
)
data class Score(
val name: String,
val score: Int,
)
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor