Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : 전체 대상에 대한 질문에 대해선 후보자 친구+비친구로 변경 #136

Merged
merged 1 commit into from
Sep 21, 2024
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 @@ -56,7 +56,7 @@ interface MemberRelationQueryRepository {
limit: Long,
): List<String>

fun findRandomOfAccompany(
fun findRandomOfAll(
memberId: String,
limit: Long,
): List<String>
Expand Down Expand Up @@ -142,7 +142,7 @@ class MemberRelationQueryRepositoryImpl(
.fetch()
}

override fun findRandomOfAccompany(
override fun findRandomOfAll(
memberId: String,
limit: Long,
): List<String> {
Expand All @@ -151,10 +151,7 @@ class MemberRelationQueryRepositoryImpl(
return jpaQueryFactory
.select(memberRelation.toId)
.from(memberRelation)
.where(
memberRelation.fromId.eq(memberId),
memberRelation.relationType.eq(RelationType.ACCOMPANY)
)
.where(memberRelation.fromId.eq(memberId))
.orderBy(Expressions.numberTemplate(Double::class.java, "function('RAND')").asc())
.limit(8)
.fetch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface MemberRelationService {

fun findCandidateOfFriend(memberId: MemberId): List<MemberId>

fun findCandidateOfAccompany(memberId: MemberId): List<MemberId>
fun findCandidateOfAll(memberId: MemberId): List<MemberId>

fun findRelationByIds(
fromId: MemberId,
Expand Down Expand Up @@ -123,8 +123,8 @@ class DefaultMemberRelationService(
}
}

override fun findCandidateOfAccompany(memberId: MemberId): List<MemberId> {
return memberRelationRepository.findRandomOfAccompany(
override fun findCandidateOfAll(memberId: MemberId): List<MemberId> {
return memberRelationRepository.findRandomOfAll(
memberId = memberId.value,
limit = defaultCandidateSize
).map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface QuestionService {
questionId: QuestionId,
resolver: MemberId,
candidatesOfFriend: List<MemberId>,
candidatesOfAccompany: List<MemberId>,
candidatesOfAll: List<MemberId>,
questionType: QuestionType,
): QuestionSheet

Expand Down Expand Up @@ -252,7 +252,7 @@ class DefaultQuestionService(
questionId: QuestionId,
resolver: MemberId,
candidatesOfFriend: List<MemberId>,
candidatesOfAccompany: List<MemberId>,
candidatesOfAll: List<MemberId>,
questionType: QuestionType,
): QuestionSheet {
/**
Expand All @@ -262,19 +262,15 @@ class DefaultQuestionService(
* 질문의 타입에 따라 적절한 후보자 리스트를 사용
*/

if (candidatesOfFriend.size < defaultCandidateSize && candidatesOfAccompany.size < defaultCandidateSize) {
if (candidatesOfFriend.size < defaultCandidateSize && candidatesOfAll.size < defaultCandidateSize) {
throw DojoException.of(DojoExceptionType.CANDIDATE_INVALID_SIZE)
}

val candidates =
when (questionType) {
QuestionType.FRIEND ->
// 친구 후보자의 크기가 기본 크기보다 작을 경우 비친구 후보자를 사용
if (candidatesOfFriend.size < defaultCandidateSize) candidatesOfAccompany else candidatesOfFriend

QuestionType.ACCOMPANY ->
// 비친구 후보자의 크기가 기본 크기보다 작을 경우 친구 후보자를 사용
if (candidatesOfAccompany.size < defaultCandidateSize) candidatesOfFriend else candidatesOfAccompany
// 친구 후보자의 크기가 기본 크기보다 작을 경우 전체 후보자를 사용
QuestionType.FRIEND -> if (candidatesOfFriend.size < defaultCandidateSize) candidatesOfAll else candidatesOfFriend
QuestionType.ACCOMPANY -> candidatesOfAll
}

return QuestionSheet.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class DefaultQuestionUseCase(
val questionSheets =
questions.map { questionOrder ->
val candidatesOfFriend = memberRelationService.findCandidateOfFriend(member.id)
val candidatesOfAccompany = memberRelationService.findCandidateOfAccompany(member.id)

// all -> accompany + friend
val candidatesOfAll = memberRelationService.findCandidateOfAll(member.id)
val questionType = questionOrder.type

// 질문의 타입에 따라 다른 후보자 리스트를 전달
Expand All @@ -147,7 +147,7 @@ class DefaultQuestionUseCase(
questionType = questionType,
resolver = member.id,
candidatesOfFriend = candidatesOfFriend,
candidatesOfAccompany = candidatesOfAccompany
candidatesOfAll = candidatesOfAll
)
}
questionSheets
Expand Down
Loading