Skip to content

Commit

Permalink
fix: 내가 참여한 스터디 JOIN 쿼리 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jaejae-yoo committed Aug 8, 2022
1 parent 53e801a commit e39733f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class MyStudyDao {
public List<MyStudySummaryData> findMyStudyByMemberId(Long id) {
String sql = "SELECT DISTINCT study.id, study.title, study.study_status, study.current_member_count, "
+ "study.max_member_count, study.start_date, study.end_date "
+ "FROM study_member JOIN study ON study_member.study_id = study.id "
+ "FROM study LEFT JOIN study_member ON study_member.study_id = study.id "
+ "WHERE study_member.member_id = :id OR study.owner_id = :id";

return jdbcTemplate.query(sql, Map.of("id", id), MY_STUDY_SUMMARY_ROW_MAPPER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ void initDataBase() {
+ "VALUES (5, '알고리즘 스터디', '알고리즘 설명', 'algorithm thumbnail', 'RECRUITMENT_END', 'PREPARE', '알고리즘을 TDD로 풀자의 베루스입니다.', 1, '" + now + "', 4, '2021-12-06')");
jdbcTemplate.update("INSERT INTO study(id, title, excerpt, thumbnail, recruitment_status, study_status, description, current_member_count, created_at, owner_id, start_date, enrollment_end_date, end_date) "
+ "VALUES (6, 'Linux 스터디', '리눅스 설명', 'linux thumbnail', 'RECRUITMENT_END', 'PREPARE', 'Linux를 공부하자의 베루스입니다.', 1, '" + now + "', 4, '2021-12-06', '2021-12-07', '2022-01-07')");
jdbcTemplate.update("INSERT INTO study(id, title, excerpt, thumbnail, recruitment_status, study_status, description, current_member_count, created_at, owner_id, start_date, enrollment_end_date, end_date) "
+ "VALUES (7, 'OS 스터디', 'OS 설명', 'os thumbnail', 'RECRUITMENT_END', 'PREPARE', 'OS를 공부하자의 그린론입니다.', 1, '" + now + "', 2, '2021-12-06', '2021-12-07', '2022-01-07')");


jdbcTemplate.update("INSERT INTO category(id, name) VALUES (1, 'generation')");
jdbcTemplate.update("INSERT INTO category(id, name) VALUES (2, 'area')");
Expand Down Expand Up @@ -93,14 +96,14 @@ void getMyStudies() {
final List<MyStudySummaryData> studySummaryData = myStudyDao.findMyStudyByMemberId(2L);

assertThat(studySummaryData)
.hasSize(3)
.hasSize(4)
.filteredOn(myStudySummaryData -> myStudySummaryData.getId() != null)
.extracting("title", "studyStatus", "currentMemberCount", "maxMemberCount", "startDate", "endDate")
.contains(
tuple("Java 스터디", PREPARE, 3, 10, "2021-12-08", null),
tuple("javaScript 스터디" ,PREPARE, 3, 20, "2022-08-03", null),
tuple("React 스터디", PREPARE, 4, 5, "2021-11-10", "2021-12-08"),
tuple("React 스터디", PREPARE, 4, 5, "2021-11-10", "2021-12-08")
tuple("OS 스터디", PREPARE, 1, 0, "2021-12-06", "2022-01-07")
);
}

Expand Down

0 comments on commit e39733f

Please sign in to comment.