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

[버그] 분석 기능 오류 발생 #127

Merged
merged 2 commits into from
Sep 7, 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
8 changes: 4 additions & 4 deletions src/docs/asciidoc/analysis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== 전형별 지원자 수 조회
전형별 지원자들의 수를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/request-headers.adoc[]
Expand All @@ -17,7 +17,7 @@ include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한
=== 전형별 성적 분포 조회
1차 합격자, 2차 전형자, 최종 합격자들의 전형별 성적 분포를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/request-headers.adoc[]
Expand All @@ -44,7 +44,7 @@ include::{snippets}/analysis-controller-test/최종_합격자들의_성적_분
=== 전형별 성비 조회
1차 합격자, 2차 전형자, 최종 합격자들의 전형별, 지역별 성비를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/request-headers.adoc[]
Expand All @@ -63,7 +63,7 @@ include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/ht
=== 전형별 출신학교 조회
1차 합격자, 2차 전형자, 최종 합격자들의 출신학교를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/request-headers.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ public class QuerySchoolStatusUseCase {
private final FormRepository formRepository;

public List<SchoolStatusResponse> execute(SchoolStatusRequest request) {
String keyword = request.getIsBusan() ? "부산광역시" : "";
keyword += request.getGu() == null ? "" : (" " + request.getGu());
if (request.getIsBusan()) {
String keyword = "부산광역시";
keyword += request.getGu() == null ? "" : (" " + request.getGu());

return formRepository.findSchoolByAddress(request.getStatusList(), keyword)
return formRepository.findSchoolByAddress(request.getStatusList(), keyword)
.stream()
.map(SchoolStatusResponse::new)
.toList();
}

return formRepository.findNotBusanSchool(request.getStatusList())
.stream()
.map(SchoolStatusResponse::new)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ public interface FormRepositoryCustom {
List<NumberOfApplicantsVo> findTypeAndCountGroupByType();
List<GradeVo> findGradeGroupByTypeAndStatus(List<FormStatus> round);
List<SchoolStatusVo> findSchoolByAddress(List<FormStatus> round, String keyword);
List<SchoolStatusVo> findNotBusanSchool(List<FormStatus> round);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.bamdoliro.maru.domain.form.domain.Form;
import com.bamdoliro.maru.domain.form.domain.type.FormStatus;
import com.bamdoliro.maru.domain.form.domain.type.FormType;
import com.bamdoliro.maru.domain.form.domain.value.QSchool;
import com.bamdoliro.maru.infrastructure.persistence.form.vo.*;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand Down Expand Up @@ -285,4 +286,17 @@ public List<SchoolStatusVo> findSchoolByAddress(List<FormStatus> round, String k
.and(form.status.in(round)))
.fetch();
}

@Override
public List<SchoolStatusVo> findNotBusanSchool(List<FormStatus> round) {
return queryFactory
.select(new QSchoolStatusVo(
form.applicant.name,
form.education.school.name,
form.education.school.address
))
.from(form)
.where(form.education.school.location.eq("부산광역시").not())
.fetch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class QuerySchoolStatusUseCaseTest {
new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1")
);
List<FormStatus> round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED);
given(formRepository.findSchoolByAddress(round, "")).willReturn(voList);
given(formRepository.findNotBusanSchool(round)).willReturn(voList);
SchoolStatusRequest request = new SchoolStatusRequest(round, false, null);

// when
List<SchoolStatusResponse> responseList = querySchoolStatusUseCase.execute(request);

// then
Assertions.assertEquals(responseList.size(), voList.size());
verify(formRepository, times(1)).findSchoolByAddress(round, "");
verify(formRepository, times(1)).findNotBusanSchool(round);
}

@Test
Expand Down Expand Up @@ -98,15 +98,15 @@ class QuerySchoolStatusUseCaseTest {
new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1")
);
List<FormStatus> round = List.of(FormStatus.FAILED, FormStatus.PASSED);
given(formRepository.findSchoolByAddress(round, "")).willReturn(voList);
given(formRepository.findNotBusanSchool(round)).willReturn(voList);
SchoolStatusRequest request = new SchoolStatusRequest(round, false, null);

// when
List<SchoolStatusResponse> responseList = querySchoolStatusUseCase.execute(request);

// then
Assertions.assertEquals(responseList.size(), voList.size());
verify(formRepository, times(1)).findSchoolByAddress(round, "");
verify(formRepository, times(1)).findNotBusanSchool(round);
}

@Test
Expand Down Expand Up @@ -159,15 +159,15 @@ class QuerySchoolStatusUseCaseTest {
new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1")
);
List<FormStatus> round = List.of(FormStatus.PASSED);
given(formRepository.findSchoolByAddress(round, "")).willReturn(voList);
given(formRepository.findNotBusanSchool(round)).willReturn(voList);
SchoolStatusRequest request = new SchoolStatusRequest(round, false, null);

// when
List<SchoolStatusResponse> responseList = querySchoolStatusUseCase.execute(request);

// then
Assertions.assertEquals(responseList.size(), voList.size());
verify(formRepository, times(1)).findSchoolByAddress(round, "");
verify(formRepository, times(1)).findNotBusanSchool(round);
}

@Test
Expand Down
Loading