feat(relationship): add findAllSpouseEdges() for timeline assembly
Returns all SPOUSE_OF edges with JOIN FETCH on both person sides, preventing N+1 in TimelineService.assembleDerivedEvents() (REQ-011). Reuses existing findAllByRelationTypeIn query which already JOIN FETCHes. Refs #776 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,15 @@ public class RelationshipService {
|
|||||||
return new NetworkDTO(nodes, edges);
|
return new NetworkDTO(nodes, edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@code SPOUSE_OF} edges with both person sides JOIN FETCHed.
|
||||||
|
* Used by {@code TimelineService.assembleDerivedEvents()} to build Heirat events
|
||||||
|
* without per-edge N+1 queries.
|
||||||
|
*/
|
||||||
|
public List<PersonRelationship> findAllSpouseEdges() {
|
||||||
|
return relationshipRepository.findAllByRelationTypeIn(List.of(RelationType.SPOUSE_OF));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public RelationshipDTO addRelationship(UUID personId, CreateRelationshipRequest dto) {
|
public RelationshipDTO addRelationship(UUID personId, CreateRelationshipRequest dto) {
|
||||||
if (personId.equals(dto.relatedPersonId())) {
|
if (personId.equals(dto.relatedPersonId())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user