Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface FamilyRelationJpaRepository extends JpaRepository<FamilyRelatio
select new com.oneco.backend.StudyRecord.application.dto.result.MemberItem(m.id, m.name)
from FamilyRelation f
join Member m on m.id = f.childId.value
where f.parentId = :parentId
where f.parentId.value = :parentId
and f.status = 'CONNECTED'
""")
List<MemberItem> findAllConnectedChildrenByParentId(@Param("parentId") Long parentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ public MissionDetailResponse getMissionDetailById(MemberId memberId, Long missio

String categoryTitle = categoryLookupPort.getCategoryTitle(mission.getCategoryId()).getValue();
String rewardTitle = mission.getReward() == null ? null : mission.getReward().getTitle();
String rewardMessage = mission.getReward() == null? null : mission.getReward().getMessage();
// 요청자 닉네임 조회
String rewardMessage = mission.getReward() == null ? null : mission.getReward().getMessage();
// 수신자, 요청자 닉네임 조회
Member recipient = memberJpaRepository.findById(mission.getRecipientId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
Member requester = memberJpaRepository.findById(mission.getRequesterId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
Comment on lines +135 to +139

Copilot AI Jan 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two sequential database calls are made to fetch recipient and requester members separately. Consider optimizing this by fetching both members in a single query using findAllById method, which would reduce the number of database round trips from 2 to 1.

Suggested change
// 수신자, 요청자 닉네임 조회
Member recipient = memberJpaRepository.findById(mission.getRecipientId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
Member requester = memberJpaRepository.findById(mission.getRequesterId().getValue())
.orElseThrow(() -> BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND));
// 수신자, 요청자 닉네임 조회 - 두 번의 단건 조회 대신 한 번의 다건 조회 사용
Long recipientId = mission.getRecipientId().getValue();
Long requesterId = mission.getRequesterId().getValue();
List<Member> members = memberJpaRepository.findAllById(Arrays.asList(recipientId, requesterId));
java.util.Map<Long, Member> memberMap = members.stream()
.collect(Collectors.toMap(member -> member.getId().getValue(), member -> member));
Member recipient = memberMap.get(recipientId);
if (recipient == null) {
throw BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND);
}
Member requester = memberMap.get(requesterId);
if (requester == null) {
throw BaseException.from(MissionErrorCode.MEMBER_NOT_FOUND);
}

Copilot uses AI. Check for mistakes.
return MissionDetailResponse.of(
mission.getId(),
categoryTitle,
Expand All @@ -146,7 +148,8 @@ public MissionDetailResponse getMissionDetailById(MemberId memberId, Long missio
memberId.getValue(),
mission.getRecipientId().getValue(),
mission.getRequesterId().getValue(),
recipient.getNickname()
recipient.getNickname(),
requester.getNickname()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public record MissionDetailResponse(
Long memberId,
Long recipientId,
Long requesterId,
String recipientNickname
String recipientNickname,
String requesterNickname
) {
public static MissionDetailResponse of(
Long missionId,
Expand All @@ -26,9 +27,10 @@ public static MissionDetailResponse of(
Long memberId,
Long recipientId,
Long requesterId,
String recipientNickname
String recipientNickname,
String requesterNickname
) {
return new MissionDetailResponse(missionId, categoryTitle, rewardTitle,rewardMessage, startDate, endDate, missionStatus,
memberId, recipientId, requesterId, recipientNickname);
return new MissionDetailResponse(missionId, categoryTitle, rewardTitle, rewardMessage, startDate, endDate, missionStatus,
memberId, recipientId, requesterId, recipientNickname, requesterNickname);
}
}
Loading