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

[BE] feat: 라인업이 공개된 축제가 인기 라인업으로 검색되게 변경 (#971) #973

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -15,6 +15,7 @@
import com.festago.common.exception.dto.ValidErrorResponse;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.apache.catalina.connector.ClientAbortException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -63,6 +64,11 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

private final AuthenticateContext authenticateContext;

@ExceptionHandler(ClientAbortException.class)
public ResponseEntity<ErrorResponse> handle(ClientAbortException e) {
return ResponseEntity.badRequest().build();
}

@ExceptionHandler(InvalidMediaTypeException.class)
public ResponseEntity<ErrorResponse> handle(InvalidMediaTypeException e) {
return ResponseEntity.badRequest().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public List<FestivalV1Response> findPopularFestivals() {
festivalQueryInfo.artistInfo)
)
.from(festival)
.where(festivalQueryInfo.artistInfo.ne("[]"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

끝난 축제가 보인다는 피드백이 있어서, 해당 내용도 반영해야 할 것 같네요!

.where(festival.festivalDuration.endDate.gt(now)
                .and((festivalQueryInfo.artistInfo.ne("[]"))))

Copy link
Member Author

Choose a reason for hiding this comment

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

반영했습니다!

.innerJoin(school).on(school.id.eq(festival.school.id))
.innerJoin(festivalQueryInfo).on(festivalQueryInfo.festivalId.eq(festival.id))
.orderBy(festival.id.desc())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class PopularFestivalV1QueryServiceIntegrationTest extends ApplicationIntegratio
PopularFestivalV1QueryService popularQueryService;

@Autowired
FestivalRepository festivalRepository;
SchoolRepository schoolRepository;

@Autowired
FestivalInfoRepository festivalInfoRepository;
FestivalRepository festivalRepository;

@Autowired
SchoolRepository schoolRepository;
FestivalInfoRepository festivalInfoRepository;

School 대학교;

Expand All @@ -45,29 +45,51 @@ class PopularFestivalV1QueryServiceIntegrationTest extends ApplicationIntegratio
Festival 여섯번째로_저장된_축제;
Festival 일곱번째로_저장된_축제;
Festival 여덟번째로_저장된_축제;
Festival 아홉번째로_저장된_공연없는_축제;
Festival 열번째로_저장된_공연없는_축제;

@BeforeEach
void setUp() {
대학교 = schoolRepository.save(SchoolFixture.builder().build());

첫번째로_저장된_축제 = createFestival();
두번째로_저장된_축제 = createFestival();
세번째로_저장된_축제 = createFestival();
네번째로_저장된_축제 = createFestival();
다섯번째로_저장된_축제 = createFestival();
여섯번째로_저장된_축제 = createFestival();
일곱번째로_저장된_축제 = createFestival();
여덟번째로_저장된_축제 = createFestival();
첫번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
두번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
세번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
네번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
다섯번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
여섯번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
일곱번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
여덟번째로_저장된_축제 = createFestivalWithFilledFestivalInfo();
아홉번째로_저장된_공연없는_축제 = createFestivalWithEmptyFestivalInfo();
열번째로_저장된_공연없는_축제 = createFestivalWithEmptyFestivalInfo();
}

private Festival createFestivalWithFilledFestivalInfo() {
Festival festival = festivalRepository.save(FestivalFixture.builder().school(대학교).build());
festivalInfoRepository.save(makeBaseFixture(festival)
.artistInfo("""
{
notEmpty
}
""")
.build());
return festival;
}

private FestivalQueryInfoFixture makeBaseFixture(Festival festival) {
return FestivalQueryInfoFixture.builder()
.festivalId(festival.getId());
}

private Festival createFestival() {
private Festival createFestivalWithEmptyFestivalInfo() {
Festival festival = festivalRepository.save(FestivalFixture.builder().school(대학교).build());
festivalInfoRepository.save(FestivalQueryInfoFixture.builder().festivalId(festival.getId()).build());
festivalInfoRepository.save(makeBaseFixture(festival)
.build());
return festival;
}

@Test
void 인기_축제는_7개까지_반환되고_식별자의_내림차순으로_정렬되어_조회된다() {
void 인기_축제는_공연이등록된_축제중_7개까지_반환되고_식별자의_내림차순으로_정렬되어_조회된다() {
// when
var expect = popularQueryService.findPopularFestivals().content();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class FestivalQueryInfoFixture extends BaseFixture {

private Long festivalId;
private String artistInfo = "";
private String artistInfo = "[]";

private FestivalQueryInfoFixture() {
}
Expand Down
Loading