refactor(transcription): drop dead existsById orphan guard from listener
Felix #2 / Markus #1 (PR #366 review). In the synchronous-transactional path the existsById check could never return false — the rename and the propagation share one transaction, so the renamed Person is guaranteed to still exist when the listener runs. The check was forward-protection for an eventual @Async refactor but its presence today is misleading: it suggests a runtime branch that no test could reach against the real flow. Delete the call, drop the PersonService dependency from the listener, drop the now-unused PersonService.existsById, and remove the orphan-guard test (it asserted a behaviour that the synchronous path cannot produce). When async is added later the guard re-enters the codebase deliberately as part of that refactor. Refs #362 #366 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -33,16 +33,10 @@ import java.util.regex.Pattern;
|
||||
public class PersonMentionPropagationListener {
|
||||
|
||||
private final TranscriptionBlockRepository blockRepository;
|
||||
private final PersonService personService;
|
||||
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void onPersonDisplayNameChanged(PersonDisplayNameChangedEvent event) {
|
||||
if (!personService.existsById(event.personId())) {
|
||||
log.warn("Skipping mention propagation for non-existent personId {}", event.personId());
|
||||
return;
|
||||
}
|
||||
|
||||
List<TranscriptionBlock> blocks =
|
||||
blockRepository.findByMentionedPersons_PersonId(event.personId());
|
||||
if (blocks.isEmpty()) {
|
||||
|
||||
@@ -51,10 +51,6 @@ public class PersonService {
|
||||
.orElseThrow(() -> DomainException.notFound(ErrorCode.PERSON_NOT_FOUND, "Person not found: " + id));
|
||||
}
|
||||
|
||||
public boolean existsById(UUID id) {
|
||||
return personRepository.existsById(id);
|
||||
}
|
||||
|
||||
public List<Person> findCorrespondents(UUID personId, String q) {
|
||||
if (q != null && !q.isBlank()) {
|
||||
return personRepository.findCorrespondentsWithFilter(personId, q);
|
||||
|
||||
Reference in New Issue
Block a user