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
3 changes: 2 additions & 1 deletion src/main/java/com/dokdok/meeting/api/MyMeetingListApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public interface MyMeetingListApi {
"endDateTime": "2025-02-01T16:00:00",
"meetingStatus": "CONFIRMED",
"myRole": "LEADER",
"progressStatus": "UPCOMING"
"progressStatus": "UPCOMING",
"preOpinionTemplateConfirmed": true
}
],
"totalCount": 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public record MyMeetingListItemResponse(
MeetingMyRole myRole,

@Schema(description = "약속 진행 상태(시간 기준)", example = "UPCOMING")
MeetingProgressStatus progressStatus
MeetingProgressStatus progressStatus,

@Schema(description = "사전 의견 템플릿 확정 여부", example = "true")
boolean preOpinionTemplateConfirmed
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dokdok.meeting.entity.MeetingMember;
import com.dokdok.meeting.entity.MeetingStatus;
import com.dokdok.meeting.entity.Meeting;
import com.dokdok.retrospective.entity.PersonalMeetingRetrospective;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
Expand Down Expand Up @@ -105,6 +106,23 @@ int countMyMeetingsByStatus(
@Param("meetingStatus") MeetingStatus meetingStatus
);

@Query("""
SELECT count(mm) FROM MeetingMember mm
JOIN mm.meeting m
WHERE mm.user.id = :userId
AND mm.canceledAt IS NULL
AND m.meetingStatus = :meetingStatus
AND NOT EXISTS (
SELECT 1 FROM PersonalMeetingRetrospective pmr
WHERE pmr.meeting = m
AND pmr.user.id = :userId
)
""")
int countMyMeetingsByStatusWithoutPersonalRetrospective(
@Param("userId") Long userId,
@Param("meetingStatus") MeetingStatus meetingStatus
);

@Query("""
SELECT count(mm) FROM MeetingMember mm
JOIN mm.meeting m
Expand Down Expand Up @@ -216,6 +234,34 @@ List<Meeting> findMyMeetingsByStatusAfterCursor(
Pageable pageable
);

@Query(
value = """
SELECT m FROM MeetingMember mm
JOIN mm.meeting m
JOIN FETCH m.book
JOIN FETCH m.gathering
WHERE mm.user.id = :userId
AND mm.canceledAt IS NULL
AND m.meetingStatus = :meetingStatus
AND NOT EXISTS (
SELECT 1 FROM PersonalMeetingRetrospective pmr
WHERE pmr.meeting = m
AND pmr.user.id = :userId
)
AND (CAST(:cursorStartDateTime AS timestamp) IS NULL
OR m.meetingStartDate > :cursorStartDateTime
OR (m.meetingStartDate = :cursorStartDateTime AND m.id > :cursorMeetingId))
ORDER BY m.meetingStartDate ASC, m.id ASC
"""
)
List<Meeting> findMyDoneMeetingsWithoutPersonalRetrospectiveAfterCursor(
@Param("userId") Long userId,
@Param("meetingStatus") MeetingStatus meetingStatus,
@Param("cursorStartDateTime") LocalDateTime cursorStartDateTime,
@Param("cursorMeetingId") Long cursorMeetingId,
Pageable pageable
);

@Query(
value = """
SELECT m FROM MeetingMember mm
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/com/dokdok/meeting/service/MeetingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ public CursorResponse<MyMeetingListItemResponse, MeetingListCursor> getMyMeeting
cursorMeetingId(cursor),
pageable
);
case DONE -> meetingMemberRepository.findMyMeetingsByStatusAfterCursor(
case DONE -> meetingMemberRepository.findMyDoneMeetingsWithoutPersonalRetrospectiveAfterCursor(
userId,
MeetingStatus.DONE,
cursorStartDateTime(cursor),
Expand All @@ -691,7 +691,7 @@ public CursorResponse<MyMeetingListItemResponse, MeetingListCursor> getMyMeeting
now,
now.plusDays(3)
);
case DONE -> meetingMemberRepository.countMyMeetingsByStatus(
case DONE -> meetingMemberRepository.countMyMeetingsByStatusWithoutPersonalRetrospective(
userId,
MeetingStatus.DONE
);
Expand Down Expand Up @@ -724,7 +724,7 @@ public MyMeetingTabCountsResponse getMyMeetingTabCounts() {
now,
now.plusDays(3)
);
int doneCount = meetingMemberRepository.countMyMeetingsByStatus(
int doneCount = meetingMemberRepository.countMyMeetingsByStatusWithoutPersonalRetrospective(
userId,
MeetingStatus.DONE
);
Expand Down Expand Up @@ -899,13 +899,21 @@ private List<MyMeetingListItemResponse> buildMyMeetingItems(List<Meeting> meetin
LocalDateTime now = LocalDateTime.now();
List<MyMeetingListItemResponse> items = new ArrayList<>();

List<Long> meetingIds = meetings.stream()
.map(Meeting::getId)
.toList();
Set<Long> meetingIdsWithConfirmedTopics = new HashSet<>(
topicRepository.findMeetingIdsWithConfirmedTopics(meetingIds)
);

for (Meeting meeting : meetings) {
MeetingProgressStatus progressStatus = resolveProgressStatus(
meeting.getMeetingStartDate(),
meeting.getMeetingEndDate(),
now
);
MeetingMyRole myRole = resolveMyMeetingRole(meeting, userId);
boolean preOpinionTemplateConfirmed = meetingIdsWithConfirmedTopics.contains(meeting.getId());

items.add(new MyMeetingListItemResponse(
meeting.getId(),
Expand All @@ -918,7 +926,8 @@ private List<MyMeetingListItemResponse> buildMyMeetingItems(List<Meeting> meetin
meeting.getMeetingEndDate(),
meeting.getMeetingStatus(),
myRole,
progressStatus
progressStatus,
preOpinionTemplateConfirmed
));
}
return items;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/dokdok/topic/repository/TopicRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ List<Topic> findTopicsInfoByMeetingIds(
@Param("meetingIds") List<Long> meetingIds
);

@Query("""
SELECT DISTINCT t.meeting.id
FROM Topic t
WHERE t.meeting.id IN :meetingIds
AND t.topicStatus = com.dokdok.topic.entity.TopicStatus.CONFIRMED
AND t.deletedAt IS NULL
""")
List<Long> findMeetingIdsWithConfirmedTopics(
@Param("meetingIds") List<Long> meetingIds
);

@Query("""
SELECT MAX(t.updatedAt)
FROM Topic t
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/com/dokdok/meeting/service/MeetingServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,8 @@ void givenNullFilter_whenGetMyMeetingList_thenReturnItems() {
any(),
any()
)).willReturn(List.of(myMeeting));
given(topicRepository.findMeetingIdsWithConfirmedTopics(List.of(myMeeting.getId())))
.willReturn(List.of(myMeeting.getId()));

try (MockedStatic<SecurityUtil> mock = mockStatic(SecurityUtil.class)) {
mock.when(SecurityUtil::getCurrentUserId).thenReturn(userId);
Expand Down Expand Up @@ -1482,6 +1484,8 @@ void givenUpcomingFilter_whenGetMyMeetingList_thenReturnUpcomingItems() {
any(),
any()
)).willReturn(List.of(upcomingMeeting));
given(topicRepository.findMeetingIdsWithConfirmedTopics(List.of(upcomingMeeting.getId())))
.willReturn(List.of());

try (MockedStatic<SecurityUtil> mock = mockStatic(SecurityUtil.class)) {
mock.when(SecurityUtil::getCurrentUserId).thenReturn(userId);
Expand Down Expand Up @@ -1512,8 +1516,10 @@ void givenUser_whenGetMyMeetingTabCounts_thenReturnCounts() {
any(),
any()
)).willReturn(2);
given(meetingMemberRepository.countMyMeetingsByStatus(userId, MeetingStatus.DONE))
.willReturn(3);
given(meetingMemberRepository.countMyMeetingsByStatusWithoutPersonalRetrospective(
userId,
MeetingStatus.DONE
)).willReturn(3);

try (MockedStatic<SecurityUtil> mock = mockStatic(SecurityUtil.class)) {
mock.when(SecurityUtil::getCurrentUserId).thenReturn(userId);
Expand Down