diff --git a/.prober/tests/participant-completion.md b/.prober/tests/participant-completion.md index d6dc56e98..a7ac88c4c 100644 --- a/.prober/tests/participant-completion.md +++ b/.prober/tests/participant-completion.md @@ -17,7 +17,7 @@ | CP-VIEW-03 | 크루로 `GET /api/me/studies/{id}/retros/status` (반을 주지 않는다) | 200 | | CP-EDIT-01 | 네비게이터로 출석 탭에서 지난 회차의 크루 칸을 출석으로 바꿔 저장 | 저장된다. 새로고침해도 출석으로 남는다 | | CP-EDIT-02 | 네비게이터로 출석 탭에서 크루의 선택 칸을 고른다 | 선택된다. 「출석 상태」 일괄 변경을 쓸 수 있고, 「참여 중단」 버튼은 잠기며 `끝난 스터디에서는 참여 중단할 수 없습니다.` 가 보인다 | -| CP-MY-01 | 크루로 사용자 사이트 › 내 스터디룸 | 그 스터디 카드가 「참여 종료」 탭에 있고 「완주」 배지와 `완주를 축하합니다!` 출석 점수판이 보인다(완료와 완주를 나눠 보이는 일은 따로 한다 — 지금은 완료한 사람 모두에게 붙는다) | +| CP-MY-01 | 크루로 사용자 사이트 › 내 스터디룸 | 그 스터디 카드가 「참여 종료」 탭에 있다. 결석이 없으면 「완주」, 있으면 「완료」 배지다([participant-finish](participant-finish.md)) | | CP-DENY-01 | 참여를 중단한 크루로 그 스터디의 일정 탭 | 지금처럼 볼 수 없다(403) | | CP-LIST-01 | `GET /api/studies?keyword={스터디 제목}` | 그 스터디의 `currentApplicants` 가 0 이 아니라 완료한 사람 수다. `canApply` 는 `false`, `recruitStatus` 는 `null`(`ENDED` 로 저장된 뒤다. `CP-BEFORE-02` 에서는 `true` · `RECRUITING`) | | CP-LIST-02 | 백오피스 스터디 목록을 `지원 현황` 열로 내림차순 정렬 | 그 스터디의 지원 현황이 완료한 사람 수로 보이고, 그 수로 정렬된다(0명으로 맨 뒤에 가지 않는다) | diff --git a/.prober/tests/participant-finish.md b/.prober/tests/participant-finish.md new file mode 100644 index 000000000..7f6ffe345 --- /dev/null +++ b/.prober/tests/participant-finish.md @@ -0,0 +1,17 @@ +# 완주와 완료 나눠 보이기 (ZAPP #194) + +대상: stage (`backend-develop` · `core-front-develop`). 스펙 [study-participant 「완주 계산」](../../specs/study-participant/spec.md#완주-계산) · [my-studies `finished`](../../specs/my-studies/spec.md). 스테이지의 테스트 계정만 쓴다. 담당 캡틴 계정 하나, 같은 반의 크루 계정 둘(크루 A · 크루 B), 네비게이터 계정 하나로 한다. 결과 · 캡처에 실제 회원 정보와 토큰을 남기지 않는다. + +준비: 일반 스터디(프로그램 종류 `STUDY`)인 테스트 스터디 하나와 지난 정규 회차 둘 이상. 크루 A 는 지난 회차를 킥오프까지 모두 출석 · 지각 · 휴가로, 크루 B 는 정규 회차 하나만 결석으로 둔다. 킥오프 결석도 완주를 깬다(스펙 「미확정」). 그다음 [participant-completion](participant-completion.md) 의 준비대로 **DB 권한자가 그 스터디의 `STUDY.END_AT` 을 지금보다 몇 분 뒤(UTC)로 바꿔 두고**, 1~2분 뒤 두 크루가 완료(`COMPLETED`)로 바뀐 것을 확인한다. `FN-CLUB-01` 용으로 끝난 클럽 기수(프로그램 종류 `CLUB`)에 결석이 하나 있는 완료 크루가 있어야 한다. 없으면 같은 방법으로 만든다. + +| ID | 절차 | 기대 결과 | +|---|---|---| +| FN-MY-01 | 크루 A 로 사용자 사이트 › 내 스터디룸 › 「참여 종료」 탭 | 그 스터디 카드에 메달과 「완주」 배지, `완주를 축하합니다!` 출석 점수판이 보인다 | +| FN-MY-02 | 크루 B 로 같은 탭 | 그 스터디 카드에 회색 「완료」 배지와 `다음 일정 없음` 이 보이고, 메달 · 「완주」 배지 · 점수판은 없다. 카드를 누르면 그 스터디 일정으로 간다 | +| FN-MY-03 | 크루 A · B 로 각각 `GET /api/me/studies` | 그 스터디 항목의 `relation` 은 둘 다 `COMPLETED`, `finished` 는 크루 A 가 `true`, 크루 B 가 `false` | +| FN-MY-04 | 네비게이터로 출석 탭에서 크루 B 의 결석 칸을 출석으로 바꿔 저장한 뒤, 크루 B 로 내 스터디룸을 새로고침 | 그 스터디 카드가 「완주」로 바뀐다(완주는 저장하지 않고 볼 때마다 계산한다). 확인한 뒤 결석으로 되돌린다 | +| FN-ORDER-01 | 「참여 종료」 탭에 완주 카드와 완료 카드가 함께 있는 계정으로 탭을 연다 | 완주 카드가 완료 카드보다 위에 있다 | +| FN-CLUB-01 | 결석이 있는 클럽 기수의 완료 크루로 「참여 종료」 탭 | 그 기수 카드가 「완주」다(클럽은 완료한 사람 모두가 완주) | +| FN-APP-01 | 크루 B 로 모집 중인 다른 테스트 스터디에 신청한 뒤, 관리자로 `GET /api/admin/studies/{그 스터디 id}/applications` | 크루 B 신청의 `previousParticipationCount` 가 지난 완료 · 참여 중단 수이고, `completionRate` 는 그중 완주 비율이다. 위 스터디는 완주가 아니라서 분자에 들지 않는다 | + +로컬 회귀 테스트: `backend/domain/src/test/java/com/studyclub/domain/participant/` (`StudyParticipantFinishTest` · `StudyParticipantHistoryTest`), `backend/api/src/test/java/com/studyclub/api/participant/MyStudyIntegrationTest`, `backend/api/src/test/java/com/studyclub/api/application/AdminApplicationIntegrationTest` (`countsPreviousFinishesByFinishRule`), core-front `src/features/my-studies/mapper.test.ts` · `e2e/specs/joined-studies.spec.ts`. diff --git a/01-planning/stories/crew-joined-studies/PRD.md b/01-planning/stories/crew-joined-studies/PRD.md index 596615d36..59ff8eef5 100644 --- a/01-planning/stories/crew-joined-studies/PRD.md +++ b/01-planning/stories/crew-joined-studies/PRD.md @@ -4,7 +4,7 @@ 기준 프로토타입: 내 스터디 (playground 사용자 사이트 · 참여 모음) -관련 결정: [10-14 백오피스 신청자 탭 정리](../../../docs/share/2026-10-14-class-title-and-captain-applies.md) · [10-18 일정·출석 화면 피드백](../../../docs/share/2026-10-18-schedule-attendance-feedback.md) · [10-30 내 스터디의 표시·입력 시간대](../../../docs/share/2026-10-30-study-profile-timezones.md) · [11-30 Google 캘린더 권한 취소 안내](../../../docs/share/2026-11-30-calendar-revoked-guidance.md) · [11-30 캘린더 연동 처리 중 안내](../../../docs/share/2026-11-30-calendar-pending-guidance.md) · [11-30 캘린더 해제 처리 중 안내](../../../docs/share/2026-11-30-calendar-disconnecting-guidance.md) +관련 결정: [10-14 백오피스 신청자 탭 정리](../../../docs/share/2026-10-14-class-title-and-captain-applies.md) · [10-18 일정·출석 화면 피드백](../../../docs/share/2026-10-18-schedule-attendance-feedback.md) · [10-30 내 스터디의 표시·입력 시간대](../../../docs/share/2026-10-30-study-profile-timezones.md) · [11-30 Google 캘린더 권한 취소 안내](../../../docs/share/2026-11-30-calendar-revoked-guidance.md) · [11-30 캘린더 연동 처리 중 안내](../../../docs/share/2026-11-30-calendar-pending-guidance.md) · [11-30 캘린더 해제 처리 중 안내](../../../docs/share/2026-11-30-calendar-disconnecting-guidance.md) · [12-05 스터디 종료와 참여자 완료](../../../docs/share/2026-12-05-study-end-and-participant-completion.md) ## 1. 기본설명 @@ -17,7 +17,7 @@ - 참여 중인 내 스터디를 한 화면에서 모음 - 이번 주 회차를 봄 - 참여 중인 스터디의 내 분반 일정을 Google의 ‘StudyClub’ 캘린더에 연동하고 관리함 -- 시작전·참여중·참여 종료(완주·참여 중단)로 나와의 관계를 걸러 봄 +- 시작전·참여중·참여 종료(완주·완료·참여 중단)로 나와의 관계를 걸러 봄 - 스터디마다 내 역할(캡틴·네비게이터·크루)을 봄 - 카드·주간 칸을 눌러 그 스터디의 스터디 일정으로 감 (출석·디스코드·자료실은 거기서) @@ -40,7 +40,7 @@ flowchart LR 2. 처음 열면 참여중 탭임 3. 카드마다 내 역할이 「캡틴」 · 「네비게이터」 · 「크루」 중 하나로 보임 4. 카드나 주간 칸을 누르면 모집공고 상세가 아니라 그 스터디의 스터디 일정으로 감. 참여 중단 카드는 누를 수 없음 -5. 완주와 참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 +5. 완주·완료·참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 6. 정렬(다음 회차 · 시작일 · 종료일 · 이름)을 고를 수 있고, 운영하는 스터디가 있으면 역할(운영 · 참여)로 거를 수 있음 7. 내 분반 일정을 Google에 등록한 뒤에만 연동 완료를 표시한다. 연동된 계정에는 회차 추가·시간 변경을 반영하고, 해제하면 이미 등록된 일정은 유지한다 8. 권한 취소·연동 처리 중·해제 처리 중·최종 실패를 구분하고, 각 상태에서 허용된 버튼만 표시한다. 팝업을 닫아도 진행 중인 서버 작업은 취소하지 않는다. 문구는 [구글 캘린더 연동](#1-2--구글-캘린더-연동), 상태별 동작은 [캘린더 상태 계약](#캘린더-상태-계약)을 따른다 @@ -102,12 +102,13 @@ flowchart LR - **정책** - 한 번에 하나만 고름 - 처음 열면 `참여중` - - `참여 종료` = 완주 + 참여 중단. 따로 나누지 않음 + - `참여 종료` = 완주 + 완료 + 참여 중단. 따로 나누지 않음 - 참여 종료 탭 안에서는 완주 카드를 위에 둠 - **정책 — 상태 판정** - 시작전: 명부 `ACTIVE` 이고 오늘 < 기수 `START_DATE` - 참여중: 명부 `ACTIVE` 이고 오늘 >= 기수 `START_DATE` - - 완주: 명부 `COMPLETED`. 배지 문구 `완주` + - 완주: 명부 `COMPLETED` 이고 서버가 완주로 판정함(`finished`). 일반 스터디는 결석 0번, 클럽은 완료 전원. 지각·휴가는 결석이 아님. 배지 문구 `완주` + - 완료: 명부 `COMPLETED` 인데 완주가 아님(일반 스터디에서 결석이 있음). 배지 문구 `완료`, 회색 - 참여 중단: 명부 `WITHDRAWN`. 카드 상태 배지는 `종료`. 사유는 쓰지 않음 - `PAUSED`: ERD에 있음. 이 화면 탭·배지는 미정 - **데이터**: `STUDY_PARTICIPANT.STATUS`, `STUDY_COHORT.START_DATE` · `END_DATE` @@ -190,8 +191,8 @@ flowchart LR ### 4-3. 참여 상태 -- **표시**: `시작전` · `참여중` · `완주` · `종료` -- **정책**: 2번 탭과 같은 판정. 완주는 `참여 종료` 라벨을 쓰지 않음 +- **표시**: `시작전` · `참여중` · `완주` · `완료` · `종료` +- **정책**: 2번 탭과 같은 판정. 완주·완료는 `참여 종료` 라벨을 쓰지 않음 - **작업**: 상태 배지 ### 4-4. 다음 회차 @@ -199,13 +200,13 @@ flowchart LR - **표시** - 참여중·시작전: `N회차 · yyyy-mm-dd 시각`. `다가오는 일정` 라벨은 쓰지 않음 - 완주: `완주를 축하합니다!` + 참여 횟수 / 총 횟수 + `회` + 회차 칸 - - 참여 중단: `다음 일정 없음` + - 완료·참여 중단: `다음 일정 없음` - **정책** - 참여중: 오늘 이후 첫 회차 - 시작전: 1회차 - 완주: 다음 회차 대신 완주 점수판 - 참여 횟수는 강조, 총 횟수는 보조. 아래 칸은 회차마다 채움 - - 전회 출석 칩은 두지 않음. `n/n` 과 칸이 전회를 말함. 일부 회차만 참여했어도 완주면 축하 문구 + - 전회 출석 칩은 두지 않음. `n/n` 과 칸이 전회를 말함. 일반 스터디의 완주는 결석 0번이라 `n/n` 임. 종료일 뒤에 잡힌 회차는 완주를 깨지 않지만 칸에는 결석으로 보일 수 있음([완주 계산](../../../specs/study-participant/spec.md#완주-계산)). 결석이 있으면 완주가 아니라 완료라 축하 문구를 쓰지 않음. 클럽은 결석이 있어도 완주라 `n/m` 이어도 축하 문구 - 참여 횟수·총 횟수·아래 칸은 내 출석(휴가 제외)과 같음 - 날짜·시각은 내 프로필 시간대 - **데이터**: 다음 회차. 완주 시 참여 횟수·총 횟수 @@ -500,8 +501,8 @@ erDiagram | 구분 | 대상 | 지금 | 할 일 | |---|---|---|---| -| FE | core-front `/my/joined` | 있음 (#226) — `GET /api/me/studies` 로 그린다 (`features/my-studies/queries.ts`). 역할(`captain` · `participantRole`) · 참여 상태 · 다음 회차는 응답 값 | 없음 | -| BE | `GET /api/me/studies` | 구현완료 — 명부 행에 `captain` 플래그 (#326) | 없음 | +| FE | core-front `/my/joined` | 있음 (#226) — `GET /api/me/studies` 로 그린다 (`features/my-studies/queries.ts`). 역할(`captain` · `participantRole`) · 참여 상태 · 완주(`finished`, ZAPP #194) · 다음 회차는 응답 값 | 없음 | +| BE | `GET /api/me/studies` | 구현완료 — 명부 행에 `captain` 플래그 (#326) · 완주 `finished` (ZAPP #194) | 없음 | | FE | 내 분반 캘린더 연동 | Playground 시안 완료 · 실제 API 미연결 | Google 계정 선택·동의 진입, 대상 일정 수·연동 계정 조회, 아래 상태 계약에 따른 화면·버튼 및 상태 갱신 연결 | | BE | Google 캘린더 연동 | 스펙 작성 중 (#578) · 미구현 | 최초 등록·일정 변경 반영·해제·재연동, 계정·캘린더·회차별 대응 관리, 아래 상태 계약과 작업 실행 순서 보장. §4의 기술 계약 확정 | | BE | 주간 일정용 회차 (아래 API 표의 `GET /api/me/studies/{id}/meetings`) | 스펙 없음 · 컨트롤러 없음 | `GET /api/me/studies` 응답으로 충분한지 먼저 정한다 → 모자라면 [my-studies 스펙](../../../specs/my-studies/spec.md)에 더한다 | @@ -511,7 +512,7 @@ erDiagram | 대상 | 필드 | ERD | 비고 | | --- | --- | --- | --- | | 신청 | FORM_ANSWER | JSON | 행이 있으면 제출 완료. 상태값 없음. 이 화면은 명부(`STUDY_PARTICIPANT`)만. 프로토 `accepted`는 명부 `ACTIVE` | -| 명부 | STATUS | `ACTIVE` / `PAUSED` / `WITHDRAWN` / `COMPLETED` | `WITHDRAWN` = 참여 중단 → 카드 상태 배지 `종료`. `COMPLETED` = 완주. `PAUSED` 화면 미정 | +| 명부 | STATUS | `ACTIVE` / `PAUSED` / `WITHDRAWN` / `COMPLETED` | `WITHDRAWN` = 참여 중단 → 카드 상태 배지 `종료`. `COMPLETED` = 완료. 그중 완주는 서버가 판정한 `finished`. `PAUSED` 화면 미정 | | 스터디 | TITLE, STUDY_KIND, CATEGORY | `STUDY` / `CLUB` | 기간·포맷·채널·자료는 기수 | | 기수 | START_DATE, END_DATE, DISCORD_CHANNEL_URL, DRIVE_URL, STATUS | 기수 상태 `DRAFT` / `OPEN` / `CLOSED` | 모집중·진행중은 저장하지 않고 날짜로 계산 | | 반 | NAME, STARTS_AT, TIMEZONE | IANA | 참가·회차·출석의 소속 | @@ -533,6 +534,7 @@ erDiagram - 참여 상태: 명부 STATUS + 기수 시작·종료 일자. 정의 위치 서버 `STUDY_PARTICIPANT.STATUS` + `STUDY_COHORT.START_DATE`/`END_DATE`. 프로토 `joined.ts` `lifeStatus` - 다가오는 회차: 내 시간대의 오늘 이후 첫 회차 +- 완주: 서버가 판정해 `finished` 로 준다. 화면은 출석으로 다시 계산하지 않는다. 정의 위치 [완주 계산](../../../specs/study-participant/spec.md#완주-계산) - 완주 점수: 시작된 회차 중 휴가 제외 분모, 출석+지각 횟수 분자. 전회 = 분자 = 분모 - 주 제목 연·월: 그 주 월요일 - 회차 일자 표시: 내 프로필 시간대. 스터디 반 `TIMEZONE`은 UTC 예정 시각을 풀 때 쓰고, 이 화면 표시 시계는 아님 @@ -612,3 +614,5 @@ erDiagram - 클럽 로비(초대) URL을 어디에 둘지. 기수는 채널 URL만 가짐 - 아무 때나 하는 클럽의 회차 시각. 프로토는 기본 시각을 붙임 - 참여 상태 탭·페이지를 주소에 남길지 +- 완료(완주가 아닌) 카드의 배지 문구·색·점수판. 지금은 회색 `완료` 배지와 `다음 일정 없음` 이다 (ZAPP #194) +- 프로토와 `§2` 의 spec 블록은 아직 「명부 `COMPLETED` = 완주, 일부 결석이어도 축하」 기준이다. 위 4-3·4-4 와 맞출지 정한다 diff --git a/backend/api/src/main/java/com/studyclub/api/account/AdminAccountJpqlDao.java b/backend/api/src/main/java/com/studyclub/api/account/AdminAccountJpqlDao.java index 41550d75e..d3ea0df3c 100644 --- a/backend/api/src/main/java/com/studyclub/api/account/AdminAccountJpqlDao.java +++ b/backend/api/src/main/java/com/studyclub/api/account/AdminAccountJpqlDao.java @@ -29,7 +29,7 @@ @Repository class AdminAccountJpqlDao implements AdminAccountDao { - /** 「참여 중」 = 명부 행 상태. 하차·완주·탈퇴는 지난 일이라 세지 않는다. 참여 역할은 가리지 않는다 (담당 캡틴의 MEMBER 행도 센다). */ + /** 「참여 중」 = 명부 행 상태. 하차·완료·탈퇴는 지난 일이라 세지 않는다. 참여 역할은 가리지 않는다 (담당 캡틴의 MEMBER 행도 센다). */ static final List ACTIVE_STATUSES = List.of(ParticipantStatus.ACTIVE, ParticipantStatus.PAUSED); diff --git a/backend/api/src/main/java/com/studyclub/api/application/AdminApplicationQueryService.java b/backend/api/src/main/java/com/studyclub/api/application/AdminApplicationQueryService.java index 05ce2dd28..5a15f256c 100644 --- a/backend/api/src/main/java/com/studyclub/api/application/AdminApplicationQueryService.java +++ b/backend/api/src/main/java/com/studyclub/api/application/AdminApplicationQueryService.java @@ -15,11 +15,10 @@ import com.studyclub.domain.study.StudyRecruitment; import com.studyclub.domain.study.StudyRecruitmentRepository; import com.studyclub.domain.study.StudyRepository; +import java.time.Instant; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import tools.jackson.core.JacksonException; @@ -73,17 +72,13 @@ public StudyApplicationsResponse getApplications( Map histories = applicationRows.isEmpty() ? Map.of() - : studyParticipantRepository - .findHistoriesByAccountIds( + : StudyParticipantHistory.of( + studyParticipantRepository.findFinishesByAccountIds( applicationRows.stream() .map(StudyApplicationWithAccount::accountId) .toList(), - studyId) - .stream() - .collect( - Collectors.toMap( - StudyParticipantHistory::accountId, - Function.identity())); + Instant.now()), + studyId); // 사본이 없는 신청이 남은 기수는 그 뒤로 폼이 저장된 적이 없다 — 지금 폼이 그 신청이 받은 질문이다 List formQuestions = applicationRows.stream().anyMatch(row -> row.questionsSnapshot() == null) diff --git a/backend/api/src/main/java/com/studyclub/api/discord/DiscordAttendanceService.java b/backend/api/src/main/java/com/studyclub/api/discord/DiscordAttendanceService.java index 051a5a646..58042f788 100644 --- a/backend/api/src/main/java/com/studyclub/api/discord/DiscordAttendanceService.java +++ b/backend/api/src/main/java/com/studyclub/api/discord/DiscordAttendanceService.java @@ -119,7 +119,7 @@ private Map loadAccountIds(String callerDiscordId, List di * *

공부방을 여러 반이 같이 쓰므로 "그 스터디의 반장" 까지만 본다. 반장이 옆 반 멤버까지 한 번에 체크하는 게 정상 흐름이다. * - *

역할만 보면 안 된다. 하차·완주는 행을 지우지 않고 STATUS 만 바꾸므로 PARTICIPANT_ROLE 은 LEADER 로 남는다 — 지난 기수 반장이 계속 + *

역할만 보면 안 된다. 하차·완료는 행을 지우지 않고 STATUS 만 바꾸므로 PARTICIPANT_ROLE 은 LEADER 로 남는다 — 지난 기수 반장이 계속 * 출석을 찍을 수 있게 된다. 명부에 살아 있는지를 같이 본다. */ private void requireLeader( diff --git a/backend/api/src/main/java/com/studyclub/api/participant/MyStudyQueryService.java b/backend/api/src/main/java/com/studyclub/api/participant/MyStudyQueryService.java index 3d8d2db9f..6450791e8 100644 --- a/backend/api/src/main/java/com/studyclub/api/participant/MyStudyQueryService.java +++ b/backend/api/src/main/java/com/studyclub/api/participant/MyStudyQueryService.java @@ -10,6 +10,7 @@ import com.studyclub.domain.attendance.StudyAttendanceRepository; import com.studyclub.domain.participant.ParticipantStatus; import com.studyclub.domain.participant.StudyParticipant; +import com.studyclub.domain.participant.StudyParticipantFinish; import com.studyclub.domain.participant.StudyParticipantRepository; import com.studyclub.domain.study.MeetingSchedule; import com.studyclub.domain.study.Study; @@ -24,6 +25,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import org.springframework.stereotype.Service; @@ -32,7 +34,7 @@ /** * 내 스터디 목록 — 명부 행마다 스터디 하나, 내 반의 회차와 회차별 내 출석을 붙인다 (specs/my-studies/spec.md). 탭·페이징은 화면이 한다. * - *

쿼리는 명부 · 스터디 · 회차 · 출석 네 번이다. 명부 행 수와 무관하다. + *

쿼리는 명부 · 스터디 · 회차 · 출석 · 프로그램 · 완주 재료 여섯 번이다. 명부 행 수와 무관하다. */ @Service public class MyStudyQueryService { @@ -62,6 +64,7 @@ public MyStudyListResponse getMyStudies(Long accountId) { if (participants.isEmpty()) { return new MyStudyListResponse(List.of()); } + Instant now = Instant.now(); List studyIds = participants.stream().map(StudyParticipant::getStudyId).toList(); List groupIds = participants.stream().map(StudyParticipant::getStudyGroupId).toList(); @@ -86,8 +89,14 @@ public MyStudyListResponse getMyStudies(Long accountId) { .toList()) .stream() .collect(Collectors.toMap(StudyProgram::getId, p -> p)); + Set finishedParticipantIds = + studyParticipantRepository + .findFinishesByAccountIds(List.of(accountId), now) + .stream() + .filter(StudyParticipantFinish::finished) + .map(StudyParticipantFinish::participantId) + .collect(Collectors.toSet()); - Instant now = Instant.now(); List items = new ArrayList<>(); for (StudyParticipant participant : participants) { Study study = studyById.get(participant.getStudyId()); @@ -105,6 +114,7 @@ public MyStudyListResponse getMyStudies(Long accountId) { participant, study, program.getStudyKind(), + finishedParticipantIds.contains(participant.getId()), meetings, attendanceByMeetingId, now)); @@ -119,6 +129,7 @@ private MyStudy toMyStudy( StudyParticipant participant, Study study, StudyKind studyKind, + boolean finished, List meetings, Map attendanceByMeetingId, Instant now) { @@ -148,6 +159,7 @@ private MyStudy toMyStudy( study.getStartAt(), study.getEndAt(), relation, + finished, participant.getStatus(), participant.getParticipantRole(), study.isOwnedBy(participant.getAccountId()), diff --git a/backend/api/src/main/java/com/studyclub/api/participant/ParticipantHubResponses.java b/backend/api/src/main/java/com/studyclub/api/participant/ParticipantHubResponses.java index fb81a680c..37f7980b0 100644 --- a/backend/api/src/main/java/com/studyclub/api/participant/ParticipantHubResponses.java +++ b/backend/api/src/main/java/com/studyclub/api/participant/ParticipantHubResponses.java @@ -30,6 +30,7 @@ public record MyStudy( Instant startAt, Instant endAt, MyStudyRelation relation, + boolean finished, ParticipantStatus participantStatus, ParticipantRole participantRole, boolean captain, diff --git a/backend/api/src/main/java/com/studyclub/api/studygroup/AdminStudyParticipantService.java b/backend/api/src/main/java/com/studyclub/api/studygroup/AdminStudyParticipantService.java index 361cacf2a..bba70ac04 100644 --- a/backend/api/src/main/java/com/studyclub/api/studygroup/AdminStudyParticipantService.java +++ b/backend/api/src/main/java/com/studyclub/api/studygroup/AdminStudyParticipantService.java @@ -75,7 +75,7 @@ public AdminStudyParticipantService( * * @throws BusinessException INVALID_INPUT — 중복 participantId · 변경 필드 없음 · 다른 스터디의 반 · 반 없는 행을 * LEADER 로 - * @throws BusinessException PARTICIPANT_NOT_ACTIVE — 하차 · 탈퇴 · 완주 행 + * @throws BusinessException PARTICIPANT_NOT_ACTIVE — 하차 · 탈퇴 · 완료 행 * @throws BusinessException NOT_FOUND — 없는 스터디 · 명부 행 · 반 */ @Transactional diff --git a/backend/api/src/test/java/com/studyclub/api/application/AdminApplicationIntegrationTest.java b/backend/api/src/test/java/com/studyclub/api/application/AdminApplicationIntegrationTest.java index b833c46db..60c8c1be7 100644 --- a/backend/api/src/test/java/com/studyclub/api/application/AdminApplicationIntegrationTest.java +++ b/backend/api/src/test/java/com/studyclub/api/application/AdminApplicationIntegrationTest.java @@ -5,7 +5,26 @@ import com.studyclub.api.auth.JwtService; import com.studyclub.domain.account.AccountRepository; import com.studyclub.domain.account.SystemRole; +import com.studyclub.domain.attendance.AttendanceStatus; +import com.studyclub.domain.attendance.StudyAttendance; +import com.studyclub.domain.attendance.StudyAttendanceRepository; +import com.studyclub.domain.participant.ParticipantRole; +import com.studyclub.domain.participant.ParticipantStatus; +import com.studyclub.domain.participant.StudyParticipant; +import com.studyclub.domain.participant.StudyParticipantRepository; +import com.studyclub.domain.study.Study; +import com.studyclub.domain.study.StudyCategory; +import com.studyclub.domain.study.StudyGroup; +import com.studyclub.domain.study.StudyGroupRepository; +import com.studyclub.domain.study.StudyKind; +import com.studyclub.domain.study.StudyMeeting; +import com.studyclub.domain.study.StudyMeetingRepository; +import com.studyclub.domain.study.StudyProgram; +import com.studyclub.domain.study.StudyProgramRepository; +import com.studyclub.domain.study.StudyRepository; +import com.studyclub.domain.study.StudyStatus; import java.sql.Timestamp; +import java.time.Duration; import java.time.Instant; import java.util.List; import java.util.Map; @@ -20,6 +39,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.jdbc.core.JdbcTemplate; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -45,6 +65,18 @@ class AdminApplicationIntegrationTest { @Autowired JdbcTemplate jdbcTemplate; + @Autowired StudyProgramRepository studyProgramRepository; + + @Autowired StudyRepository studyRepository; + + @Autowired StudyGroupRepository studyGroupRepository; + + @Autowired StudyMeetingRepository studyMeetingRepository; + + @Autowired StudyParticipantRepository studyParticipantRepository; + + @Autowired StudyAttendanceRepository studyAttendanceRepository; + @BeforeEach void seed() { Timestamp now = Timestamp.from(Instant.now()); @@ -93,6 +125,28 @@ void captainReadsApplications() { assertThat(answers).containsEntry("reason", "같이 공부하고 싶습니다."); } + @Test + @DisplayName("성공 - 지난 완주는 완료 행 수가 아니라 완주 규칙으로 센다: 일반 스터디는 결석 0번, 클럽은 완료 전원") + void countsPreviousFinishesByFinishRule() { + completedWithOneAbsence(StudyKind.STUDY); + completedWithOneAbsence(StudyKind.CLUB); + + ResponseEntity response = + rest.exchange( + "/api/admin/studies/" + STUDY_ID + "/applications", + HttpMethod.GET, + authenticatedRequest(ADMIN_ID), + Map.class); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + @SuppressWarnings("unchecked") + Map application = + (Map) ((List) response.getBody().get("applications")).get(0); + // 지난 참여 4건(완료 3 · 참여 중단 1) 중 완주는 스터디 행 없이 결석도 없는 시드 완료 행과 클럽 2건 + assertThat(application).containsEntry("previousParticipationCount", 4); + assertThat(application).containsEntry("completionRate", 50); + } + @Test @DisplayName("성공 - 사본이 없는 신청은 지금 폼 질문을 그 신청이 받은 질문으로 준다") void fallsBackToCurrentFormForApplicationWithoutSnapshot() { @@ -271,6 +325,8 @@ private void insertAccount(Long id, String email, SystemRole role, Timestamp now } private void cleanSeedRows() { + jdbcTemplate.update("DELETE FROM STUDY_ATTENDANCE WHERE ACCOUNT_ID = ?", APPLICANT_ID); + jdbcTemplate.update("DELETE FROM STUDY_PARTICIPANT WHERE ACCOUNT_ID = ?", APPLICANT_ID); jdbcTemplate.update( "DELETE FROM STUDY_APPLICATION WHERE RECRUITMENT_ID IN (?, ?)", RECRUITMENT_ID, @@ -367,6 +423,50 @@ private void insertParticipantHistory( now); } + /** 신청자가 지난달 끝난 스터디를 완료했고, 지난 회차 하나에 결석했다. */ + private void completedWithOneAbsence(StudyKind kind) { + Instant startAt = Instant.now().minus(Duration.ofDays(60)); + StudyProgram program = + studyProgramRepository.save( + StudyProgram.builder().title("지난 스터디").studyKind(kind).build()); + Study study = + studyRepository.save( + Study.builder() + .programId(program.getId()) + .title("지난 스터디") + .oneLineSummary("한 줄 소개") + .category(StudyCategory.SOFTWARE) + .status(StudyStatus.ENDED) + .startAt(startAt) + .endAt(Instant.now().minus(Duration.ofDays(30))) + .build()); + StudyGroup group = + studyGroupRepository.save( + new StudyGroup(study.getId(), "수요일반", startAt, "Asia/Seoul", 10)); + studyParticipantRepository.save( + StudyParticipant.builder() + .accountId(APPLICANT_ID) + .studyId(study.getId()) + .studyGroupId(group.getId()) + .status(ParticipantStatus.COMPLETED) + .participantRole(ParticipantRole.MEMBER) + .joinedAt(startAt) + .build()); + Instant held = startAt.plus(Duration.ofDays(7)); + Long meetingId = + studyMeetingRepository + .save(new StudyMeeting(group.getId(), held, held, null)) + .getId(); + studyAttendanceRepository.save( + StudyAttendance.builder() + .accountId(APPLICANT_ID) + .studyId(study.getId()) + .studyGroupId(group.getId()) + .studyMeetingId(meetingId) + .status(AttendanceStatus.ABSENT) + .build()); + } + private void insertApplication(Timestamp now) { jdbcTemplate.update( "INSERT INTO STUDY_APPLICATION (ACCOUNT_ID, RECRUITMENT_ID, FORM_ANSWER," diff --git a/backend/api/src/test/java/com/studyclub/api/participant/MyStudyIntegrationTest.java b/backend/api/src/test/java/com/studyclub/api/participant/MyStudyIntegrationTest.java index 7a4875097..12a156ae6 100644 --- a/backend/api/src/test/java/com/studyclub/api/participant/MyStudyIntegrationTest.java +++ b/backend/api/src/test/java/com/studyclub/api/participant/MyStudyIntegrationTest.java @@ -94,12 +94,14 @@ void splitsRelationsAndHidesLinksFromWithdrawn() { assertThat(item(items, upcoming)).containsEntry("relation", "UPCOMING"); assertThat(item(items, ongoing)) .containsEntry("relation", "ONGOING") + .containsEntry("finished", false) .containsEntry("discordChannelUrl", DISCORD_URL); assertThat(item(items, completed)) .containsEntry("relation", "COMPLETED") .containsEntry("driveUrl", DRIVE_URL); assertThat(item(items, withdrawn)) .containsEntry("relation", "WITHDRAWN") + .containsEntry("finished", false) .containsEntry("discordChannelUrl", null) .containsEntry("driveUrl", null); // 시작일 최신순 @@ -201,8 +203,175 @@ void flagsCaptainOnlyForStudiesICreated() { assertThat(item(items, others)).containsEntry("captain", false); } + @Test + @DisplayName("성공 - 완료한 일반 스터디는 결석이 0번일 때만 완주이고, 지각 · 휴가는 결석이 아니다") + void finishedOnlyWithoutAbsence() { + Long clean = + enrollEnded("결석 없음", StudyKind.STUDY, now.minus(DAY), ParticipantStatus.COMPLETED); + StudyParticipant cleanMe = participant(MEMBER_ID, clean); + attend( + cleanMe, + meeting(cleanMe, now.minus(DAY.multipliedBy(21)), true), + AttendanceStatus.PRESENT); + attend( + cleanMe, + meeting(cleanMe, now.minus(DAY.multipliedBy(14)), true), + AttendanceStatus.LATE); + attend( + cleanMe, + meeting(cleanMe, now.minus(DAY.multipliedBy(7)), true), + AttendanceStatus.EXCUSED); + Long absent = + enrollEnded("결석 1번", StudyKind.STUDY, now.minus(DAY), ParticipantStatus.COMPLETED); + StudyParticipant absentMe = participant(MEMBER_ID, absent); + attend( + absentMe, + meeting(absentMe, now.minus(DAY.multipliedBy(14)), true), + AttendanceStatus.PRESENT); + attend( + absentMe, + meeting(absentMe, now.minus(DAY.multipliedBy(7)), true), + AttendanceStatus.ABSENT); + + List> items = items(MEMBER_ID); + + assertThat(item(items, clean)) + .containsEntry("relation", "COMPLETED") + .containsEntry("finished", true); + assertThat(item(items, absent)) + .containsEntry("relation", "COMPLETED") + .containsEntry("finished", false); + } + + @Test + @DisplayName("성공 - 디스코드가 열지 않은 회차도 예정 시각이 지나면 그 결석을 센다") + void countsAbsenceInMeetingNotOpenedOnDiscord() { + Long ended = + enrollEnded( + "디스코드 없이 결석", StudyKind.STUDY, now.minus(DAY), ParticipantStatus.COMPLETED); + StudyParticipant me = participant(MEMBER_ID, ended); + attend(me, meeting(me, now.minus(DAY.multipliedBy(14)), false), AttendanceStatus.PRESENT); + attend(me, meeting(me, now.minus(DAY.multipliedBy(7)), false), AttendanceStatus.ABSENT); + + assertThat(item(items(MEMBER_ID), ended)) + .containsEntry("relation", "COMPLETED") + .containsEntry("finished", false); + } + + @Test + @DisplayName("성공 - 종료일 뒤에 잡힌 회차와 시작 전 회차에 미리 깔린 결석은 세지 않는다") + void ignoresAbsenceOutsideStudyPeriod() { + Instant endAt = now.minus(DAY.multipliedBy(3)); + Long ended = enrollEnded("종료일 뒤 회차", StudyKind.STUDY, endAt, ParticipantStatus.COMPLETED); + StudyParticipant me = participant(MEMBER_ID, ended); + attend(me, meeting(me, endAt.minus(DAY.multipliedBy(7)), true), AttendanceStatus.PRESENT); + // 종료일 뒤 회차 — 열리지 않은 것, 디스코드가 연 것, 아직 오지 않은 것 + attend(me, meeting(me, endAt.plus(DAY), false), AttendanceStatus.ABSENT); + attend(me, meeting(me, endAt.plus(DAY.multipliedBy(2)), true), AttendanceStatus.ABSENT); + attend(me, meeting(me, now.plus(DAY), false), AttendanceStatus.ABSENT); + Long noEndAt = enrollEnded("종료일 없음", StudyKind.STUDY, null, ParticipantStatus.COMPLETED); + StudyParticipant noEndMe = participant(MEMBER_ID, noEndAt); + attend( + noEndMe, + meeting(noEndMe, now.minus(DAY.multipliedBy(7)), true), + AttendanceStatus.PRESENT); + attend(noEndMe, meeting(noEndMe, now.plus(DAY), false), AttendanceStatus.ABSENT); + + List> items = items(MEMBER_ID); + + assertThat(item(items, ended)).containsEntry("finished", true); + assertThat(item(items, noEndAt)).containsEntry("finished", true); + } + + @Test + @DisplayName("성공 - 클럽은 완료하면 결석이 있어도 완주이고, 완료가 아니면 결석이 없어도 완주가 아니다") + void clubFinishesOnCompletionOnly() { + Long club = enrollEnded("클럽", StudyKind.CLUB, now.minus(DAY), ParticipantStatus.COMPLETED); + StudyParticipant clubMe = participant(MEMBER_ID, club); + attend( + clubMe, + meeting(clubMe, now.minus(DAY.multipliedBy(7)), true), + AttendanceStatus.ABSENT); + Long withdrawnClub = + enrollEnded("중단한 클럽", StudyKind.CLUB, now.minus(DAY), ParticipantStatus.WITHDRAWN); + + List> items = items(MEMBER_ID); + + assertThat(item(items, club)).containsEntry("finished", true); + assertThat(item(items, withdrawnClub)).containsEntry("finished", false); + } + + @Test + @DisplayName("성공 - 반을 옮겼으면 옛 반 회차의 결석도 센다") + void countsAbsenceInPreviousGroup() { + Long studyId = + enrollEnded("반 이동", StudyKind.STUDY, now.minus(DAY), ParticipantStatus.COMPLETED); + StudyParticipant me = participant(MEMBER_ID, studyId); + StudyGroup previous = + studyGroupRepository.save( + new StudyGroup( + studyId, + "월요일반", + now.minus(DAY.multipliedBy(60)), + "Asia/Seoul", + 10)); + Long previousMeeting = + studyMeetingRepository + .save( + new StudyMeeting( + previous.getId(), + now.minus(DAY.multipliedBy(30)), + now.minus(DAY.multipliedBy(30)), + null)) + .getId(); + studyAttendanceRepository.save( + StudyAttendance.builder() + .accountId(MEMBER_ID) + .studyId(studyId) + .studyGroupId(previous.getId()) + .studyMeetingId(previousMeeting) + .status(AttendanceStatus.ABSENT) + .build()); + attend(me, meeting(me, now.minus(DAY.multipliedBy(7)), true), AttendanceStatus.PRESENT); + + assertThat(item(items(MEMBER_ID), studyId)).containsEntry("finished", false); + } + // ── helpers ────────────────────────────────────────────────────────────── + /** 끝난 스터디 · 반 · MEMBER_ID 명부 한 줄. 60일 전에 시작했고 그때 편입했다. 종료일은 null 이면 없다. */ + private Long enrollEnded( + String title, StudyKind kind, Instant endAt, ParticipantStatus status) { + Instant startAt = now.minus(DAY.multipliedBy(60)); + StudyProgram program = + studyProgramRepository.save( + StudyProgram.builder().title(title).studyKind(kind).build()); + Study study = + studyRepository.save( + Study.builder() + .programId(program.getId()) + .title(title) + .oneLineSummary("소개") + .category(StudyCategory.SOFTWARE) + .status(StudyStatus.ENDED) + .startAt(startAt) + .endAt(endAt) + .build()); + StudyGroup group = + studyGroupRepository.save( + new StudyGroup(study.getId(), "수요일반", startAt, "Asia/Seoul", 10)); + studyParticipantRepository.save( + StudyParticipant.builder() + .accountId(MEMBER_ID) + .studyId(study.getId()) + .studyGroupId(group.getId()) + .status(status) + .participantRole(ParticipantRole.MEMBER) + .joinedAt(startAt) + .build()); + return study.getId(); + } + /** 스터디 · 반 · MEMBER_ID 명부 한 줄. 명부 편입은 10일 전. */ private Long enroll(String title, Instant startAt, ParticipantStatus status) { return enroll(title, startAt, status, null); diff --git a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipant.java b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipant.java index 9b5c0a9e3..f3c6483b3 100644 --- a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipant.java +++ b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipant.java @@ -139,7 +139,7 @@ public void markWithdrawn(Instant withdrawnAt) { /** * 네비게이터·담당 캡틴이 출석부에서 참여를 중단시킨다 (specs/study-participant/spec.md). 이미 {@code WITHDRAWN} 이면 그대로 - * 둔다 — {@code leftAt} 을 덮어쓰면 집계 분모가 바뀐다. 완주·탈퇴한 행은 바꿀 수 없다. + * 둔다 — {@code leftAt} 을 덮어쓰면 집계 분모가 바뀐다. 완료·탈퇴한 행은 바꿀 수 없다. * * @return 이번에 바뀌었으면 true, 이미 중단된 행이면 false */ diff --git a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantFinish.java b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantFinish.java new file mode 100644 index 000000000..b210d7795 --- /dev/null +++ b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantFinish.java @@ -0,0 +1,23 @@ +package com.studyclub.domain.participant; + +import com.studyclub.domain.study.StudyKind; + +/** + * 명부 행 하나의 완주 판정 재료. 쓰는 곳마다 같은 회차를 세도록 {@link StudyParticipantRepository#findFinishesByAccountIds} + * 로만 만든다. + * + * @param studyKind 스터디 행이 없으면 null + */ +public record StudyParticipantFinish( + Long participantId, + Long accountId, + Long studyId, + ParticipantStatus status, + StudyKind studyKind, + long absences) { + + public boolean finished() { + return status == ParticipantStatus.COMPLETED + && (studyKind == StudyKind.CLUB || absences == 0); + } +} diff --git a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantHistory.java b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantHistory.java index dd1b3f5dd..78d6e4960 100644 --- a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantHistory.java +++ b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantHistory.java @@ -1,13 +1,46 @@ package com.studyclub.domain.participant; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** 신청자의 지난 참여 — 이 기수를 뺀 명부 중 완료 · 참여 중단으로 끝난 참여 수와 그중 완주 수 (specs/study-application/spec.md). */ public record StudyParticipantHistory( - Long accountId, long previousParticipationCount, long completedParticipationCount) { + Long accountId, long previousParticipationCount, long finishedParticipationCount) { + + private static final Set PAST_STATUSES = + Set.of(ParticipantStatus.COMPLETED, ParticipantStatus.WITHDRAWN); + + /** 계정별로 센다. 지난 참여가 없는 계정은 결과에 없다. */ + public static Map of( + Collection finishes, Long currentStudyId) { + Map histories = new HashMap<>(); + for (StudyParticipantFinish finish : finishes) { + if (finish.studyId().equals(currentStudyId) + || !PAST_STATUSES.contains(finish.status())) { + continue; + } + histories.merge( + finish.accountId(), + new StudyParticipantHistory(finish.accountId(), 1, finish.finished() ? 1 : 0), + StudyParticipantHistory::plus); + } + return histories; + } public Integer completionRate() { if (previousParticipationCount == 0) { return null; } return Math.toIntExact( - Math.round(completedParticipationCount * 100.0 / previousParticipationCount)); + Math.round(finishedParticipationCount * 100.0 / previousParticipationCount)); + } + + private StudyParticipantHistory plus(StudyParticipantHistory other) { + return new StudyParticipantHistory( + accountId, + previousParticipationCount + other.previousParticipationCount, + finishedParticipationCount + other.finishedParticipationCount); } } diff --git a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantRepository.java b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantRepository.java index 2fa01e8d2..769ca1d74 100644 --- a/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantRepository.java +++ b/backend/domain/src/main/java/com/studyclub/domain/participant/StudyParticipantRepository.java @@ -234,20 +234,27 @@ long countByStudyIdAndStatusAndParticipantRoleIn( + " AND p.participantRole = com.studyclub.domain.participant.ParticipantRole.LEADER") List findLeadersByStudyIdIn(@Param("studyIds") Collection studyIds); + /** + * 완주 판정 재료 ({@link StudyParticipantFinish}). 내 스터디 목록과 신청자의 지난 완주 횟수가 같이 쓴다. + * + *

회차를 만들 때 반 명부 전원에게 ABSENT 가 미리 깔리므로, 시작 전 회차와 종료일 뒤에 시작한 회차는 세지 않는다. 스터디 행이 없는 명부 행도 지난 참여 + * 수에서 빠지지 않게 스터디는 바깥 조인한다. + */ @Query( - "SELECT new com.studyclub.domain.participant.StudyParticipantHistory(" - + "participant.accountId, COUNT(participant), " - + "SUM(CASE WHEN participant.status = " - + "com.studyclub.domain.participant.ParticipantStatus.COMPLETED " - + "THEN 1 ELSE 0 END)) " - + "FROM StudyParticipant participant " - + "WHERE participant.accountId IN :accountIds " - + "AND participant.studyId <> :currentStudyId " - + "AND participant.status IN (" - + "com.studyclub.domain.participant.ParticipantStatus.COMPLETED, " - + "com.studyclub.domain.participant.ParticipantStatus.WITHDRAWN) " - + "GROUP BY participant.accountId") - List findHistoriesByAccountIds( - @Param("accountIds") Collection accountIds, - @Param("currentStudyId") Long currentStudyId); + """ + SELECT new com.studyclub.domain.participant.StudyParticipantFinish( + p.id, p.accountId, p.studyId, p.status, sp.studyKind, + (SELECT COUNT(a) FROM StudyAttendance a, StudyMeeting m + WHERE a.studyMeetingId = m.id + AND a.studyId = p.studyId AND a.accountId = p.accountId + AND a.status = com.studyclub.domain.attendance.AttendanceStatus.ABSENT + AND COALESCE(m.startAt, m.scheduledAt) <= :asOf + AND (s.endAt IS NULL OR COALESCE(m.startAt, m.scheduledAt) < s.endAt))) + FROM StudyParticipant p + LEFT JOIN Study s ON s.id = p.studyId + LEFT JOIN StudyProgram sp ON sp.id = s.programId + WHERE p.accountId IN :accountIds + """) + List findFinishesByAccountIds( + @Param("accountIds") Collection accountIds, @Param("asOf") Instant asOf); } diff --git a/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantFinishTest.java b/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantFinishTest.java new file mode 100644 index 000000000..c6364fddb --- /dev/null +++ b/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantFinishTest.java @@ -0,0 +1,53 @@ +package com.studyclub.domain.participant; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.studyclub.domain.study.StudyKind; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +class StudyParticipantFinishTest { + + private static StudyParticipantFinish finish( + ParticipantStatus status, StudyKind kind, long absences) { + return new StudyParticipantFinish(1L, 1L, 1L, status, kind, absences); + } + + @Test + @DisplayName("완주 - 클럽은 완료하면 결석이 있어도 완주다") + void clubCompletedIsFinished() { + assertThat(finish(ParticipantStatus.COMPLETED, StudyKind.CLUB, 3).finished()).isTrue(); + } + + @Test + @DisplayName("완주 - 일반 스터디는 완료하고 결석이 0번이면 완주다") + void studyCompletedWithoutAbsenceIsFinished() { + assertThat(finish(ParticipantStatus.COMPLETED, StudyKind.STUDY, 0).finished()).isTrue(); + } + + @Test + @DisplayName("완주 - 일반 스터디는 결석이 1번이라도 있으면 완료일 뿐 완주가 아니다") + void studyCompletedWithAbsenceIsNotFinished() { + assertThat(finish(ParticipantStatus.COMPLETED, StudyKind.STUDY, 1).finished()).isFalse(); + } + + @Test + @DisplayName("완주 - 스터디 행이 없어 종류를 모르면 일반 스터디처럼 결석 수로 판정한다") + void unknownKindFollowsAbsences() { + assertThat(finish(ParticipantStatus.COMPLETED, null, 0).finished()).isTrue(); + assertThat(finish(ParticipantStatus.COMPLETED, null, 1).finished()).isFalse(); + } + + @ParameterizedTest + @EnumSource( + value = ParticipantStatus.class, + names = "COMPLETED", + mode = EnumSource.Mode.EXCLUDE) + @DisplayName("완주 - 완료(COMPLETED)가 아니면 클럽이어도 · 결석이 없어도 완주가 아니다") + void notCompletedIsNotFinished(ParticipantStatus status) { + assertThat(finish(status, StudyKind.CLUB, 0).finished()).isFalse(); + assertThat(finish(status, StudyKind.STUDY, 0).finished()).isFalse(); + } +} diff --git a/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantHistoryTest.java b/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantHistoryTest.java new file mode 100644 index 000000000..4a3e4e621 --- /dev/null +++ b/backend/domain/src/test/java/com/studyclub/domain/participant/StudyParticipantHistoryTest.java @@ -0,0 +1,60 @@ +package com.studyclub.domain.participant; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.studyclub.domain.study.StudyKind; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class StudyParticipantHistoryTest { + + private static final Long CURRENT_STUDY_ID = 100L; + + private static StudyParticipantFinish row( + Long accountId, Long studyId, ParticipantStatus status, StudyKind kind, long absences) { + return new StudyParticipantFinish( + accountId * 1000 + studyId, accountId, studyId, status, kind, absences); + } + + @Test + @DisplayName("지난 참여 - 이 기수를 뺀 완료 · 참여 중단 수와 그중 완주 수를 계정별로 센다") + void countsPastParticipationsAndFinishes() { + Map histories = + StudyParticipantHistory.of( + List.of( + row(1L, 1L, ParticipantStatus.COMPLETED, StudyKind.STUDY, 0), + row(1L, 2L, ParticipantStatus.COMPLETED, StudyKind.STUDY, 1), + row(1L, 3L, ParticipantStatus.COMPLETED, StudyKind.CLUB, 2), + row(1L, 4L, ParticipantStatus.WITHDRAWN, StudyKind.STUDY, 0), + row(2L, 1L, ParticipantStatus.COMPLETED, StudyKind.STUDY, 1)), + CURRENT_STUDY_ID); + + assertThat(histories.get(1L).previousParticipationCount()).isEqualTo(4); + assertThat(histories.get(1L).finishedParticipationCount()).isEqualTo(2); + assertThat(histories.get(1L).completionRate()).isEqualTo(50); + assertThat(histories.get(2L).previousParticipationCount()).isEqualTo(1); + assertThat(histories.get(2L).completionRate()).isZero(); + } + + @Test + @DisplayName("지난 참여 - 이 기수 · 진행 중 · 회원 탈퇴 행은 세지 않고, 남는 참여가 없으면 계정이 빠진다") + void skipsCurrentStudyAndUnfinishedRows() { + Map histories = + StudyParticipantHistory.of( + List.of( + row( + 1L, + CURRENT_STUDY_ID, + ParticipantStatus.COMPLETED, + StudyKind.CLUB, + 0), + row(1L, 2L, ParticipantStatus.ACTIVE, StudyKind.STUDY, 0), + row(1L, 3L, ParticipantStatus.PAUSED, StudyKind.STUDY, 0), + row(1L, 4L, ParticipantStatus.DELETED, StudyKind.STUDY, 0)), + CURRENT_STUDY_ID); + + assertThat(histories).isEmpty(); + } +} diff --git a/docs/erd/STUDY_ATTENDANCE.md b/docs/erd/STUDY_ATTENDANCE.md index 02c96b726..ea6f6f54a 100644 --- a/docs/erd/STUDY_ATTENDANCE.md +++ b/docs/erd/STUDY_ATTENDANCE.md @@ -1,7 +1,7 @@ # STUDY_ATTENDANCE — 출석 회차(STUDY_MEETING) × 회원 1행. 반장이 디스코드 명령어(`specs/discord-attendance/spec.md`)나 화면(`specs/attendance/spec.md`)에서 찍고, 사후 수정 가능. -마이페이지 출석 현황·완주율은 **여기서 계산**해서 가져간다 (다른 화면에서 재계산 금지). +마이페이지 출석 현황·출석률·완주는 **여기서 계산**해서 가져간다 (다른 화면에서 재계산 금지). ## 컬럼 @@ -19,12 +19,12 @@ ## 상태 — STATUS -| 값 | 뜻 | 완주율 계산 | +| 값 | 뜻 | 출석률 · 완주 | |---|---|---| -| `PRESENT` | 출석 | 출석 | -| `LATE` | 지각 (기준 시간은 운영 정책) | 출석 | -| `EXCUSED` | 사전 양해 결석 | 출석률 분모에서 뺀다 (2026-10-24) | -| `ABSENT` | 결석. 기본값 — 회차를 추가할 때 분반의 ACTIVE·PAUSED 참여자 행을 미리 ABSENT 로 만든다 ([회차 스펙](../../specs/study-meeting/spec.md)). 시작 전 ABSENT 는 화면에서 빈칸이다 | 결석 | +| `PRESENT` | 출석 | 출석률 1.0. 결석 아님 | +| `LATE` | 지각 (기준 시간은 운영 정책) | 출석률 0.5. 결석 아님 | +| `EXCUSED` | 사전 양해 결석 | 출석률 분모에서 뺀다 (2026-10-24). 결석 아님 | +| `ABSENT` | 결석. 기본값 — 회차를 추가할 때 분반의 ACTIVE·PAUSED 참여자 행을 미리 ABSENT 로 만든다 ([회차 스펙](../../specs/study-meeting/spec.md)). 시작 전 ABSENT 는 화면에서 빈칸이다 | 출석률 0. 일반 스터디는 시작한 회차(종료일 전)에 하나라도 있으면 완주가 아니다 | 전이 제한 없음 — 반장/운영자가 사후 수정 가능. @@ -58,4 +58,5 @@ stateDiagram-v2 ## 확정 - 행 생성 시점 — 회차를 **추가할 때** 분반의 ACTIVE·PAUSED 참여자 행을 `ABSENT` 로 만든다 (2026-10-02, [회차 스펙](../../specs/study-meeting/spec.md)). 회차 뒤에 합류한 사람은 행이 없을 수 있다 — 명부는 `status: null` 로 보인다. - 쓰기는 한 문장 upsert(`INSERT ... ON DUPLICATE KEY UPDATE`) — 조회 후 저장으로 나누면 스냅샷 읽기로 중복 INSERT 가 난다. 회차를 지우면 그 회차 행도 지운다 (`STUDY_MEETING` 으로 가는 외래키는 없다). -- 완주율 공식 — `(PRESENT×1.0 + EXCUSED×1.0 + LATE×0.5) / 전체 과거 미팅`. 분모 0이면 null("–"). 상세 산식은 `specs/attendance/spec.md` 참조. +- 출석률 공식은 [attendance 「출석률 산식」](../../specs/attendance/spec.md#출석률-산식). 분모 0이면 null("–"). +- 완주와 신청자의 지난 완주율(`completionRate`)은 [study-participant 「완주 계산」](../../specs/study-participant/spec.md#완주-계산) (2026-12-06). diff --git a/docs/frontend-development-guide/core-e2e-prd-map.md b/docs/frontend-development-guide/core-e2e-prd-map.md index 47359fb98..724b1da7c 100644 --- a/docs/frontend-development-guide/core-e2e-prd-map.md +++ b/docs/frontend-development-guide/core-e2e-prd-map.md @@ -210,7 +210,7 @@ V07 「연동 확인중」의 PRD 원문은 「스피너」지만 현재 `신청 | 2 | 처음 열면 참여중 탭임 | `CORE-ST-009-S02` | `my-joined--default` | | 3 | 카드마다 내 역할이 「캡틴」 · 「네비게이터」 · 「크루」 중 하나로 보임 | `CORE-ST-009-S03` | `my-joined--default` | | 4 | 카드나 주간 칸을 누르면 모집공고 상세가 아니라 그 스터디의 스터디 일정으로 감. 참여 중단 카드는 누를 수 없음 | `CORE-ST-009-S04` | 미연결 | -| 5 | 완주와 참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 | `CORE-ST-009-S05` | `my-joined--ended` | +| 5 | 완주·완료·참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 | `CORE-ST-009-S05` | `my-joined--ended` | | 6 | 정렬(다음 회차 · 시작일 · 종료일 · 이름)을 고를 수 있고, 운영하는 스터디가 있으면 역할(운영 · 참여)로 거를 수 있음 | `CORE-ST-009-S06` | 미연결 | | 상태 | PRD 화면·카피 | 시나리오 | 실행 화면 근거 | diff --git a/docs/share/2026-12-05-study-end-and-participant-completion.md b/docs/share/2026-12-05-study-end-and-participant-completion.md index 801de5499..5dceb8b5e 100644 --- a/docs/share/2026-12-05-study-end-and-participant-completion.md +++ b/docs/share/2026-12-05-study-end-and-participant-completion.md @@ -5,7 +5,7 @@ - specs/study-participant · study · study-recruit-status · study-application · club-cohort · domain-events, ERD STUDY · STUDY_PARTICIPANT — 됨 (#591) - 01-planning/_registry/policies/POL-0002-study-status.md (「`END_AT` 은 상태를 바꾸지 않는다」) — 됨 (2026-12-06) - 01-planning/_registry/policies/POL-0013-web-notification.md N06 행 (「`COMPLETED` 가 되면 N06」) — 확인 필요 (N06 대상 미정) - - 01-planning/stories/crew-joined-studies/PRD.md (완료와 완주 나눠 보이기) — 안 됨 (후속 이슈) + - 01-planning/stories/crew-joined-studies/PRD.md (완료와 완주 나눠 보이기) — 됨 (#597 · ZAPP #194, 프로토 spec 블록은 그대로) 공유: 공유전 --- diff --git a/docs/share/README.md b/docs/share/README.md index 4753d959a..5b79b763f 100644 --- a/docs/share/README.md +++ b/docs/share/README.md @@ -105,7 +105,7 @@ | 날짜 | 건 | 상태 | 반영 | 공유 | |---|---|---|---|---| -| 2026-12-05 | [스터디가 끝나면 시스템이 「종료」로 저장하고, 끝까지 남은 사람을 「완료」로 바꾼다](2026-12-05-study-end-and-participant-completion.md) | 결정됨 | 일부 (POL-0002 · POL-0013 N06 · crew-joined-studies PRD) | 공유전 | +| 2026-12-05 | [스터디가 끝나면 시스템이 「종료」로 저장하고, 끝까지 남은 사람을 「완료」로 바꾼다](2026-12-05-study-end-and-participant-completion.md) | 결정됨 | 일부 (POL-0013 N06 · crew-joined-studies 프로토 spec 블록) | 공유전 | | 2026-12-05 | [기존 업무 기능을 유지하고 회원 알림의 발송 조건을 확정했다](2026-12-05-web-notification-policy-decisions.md) | 결정됨 | 일부 (기획·프로토 됨, #589 spec 반영 대기) | 공유전 | | 2026-12-04 | [출결 수동 변경 알림으로 범위 조정](2026-12-04-attendance-change-notifications.md) | 결정됨 | 일부 (#589 웹 알림 스펙·계획·태스크 반영 필요) | 공유전 | | 2026-12-03 | [회원 웹 알림 생성·수신·읽음 정책](2026-12-03-web-notification-policy.md) | 결정됨 | 됨 (정책·PRD·인수 기준·기존 메일 계약 경계, 웹 API 계약 후속) | 공유전 | diff --git a/frontend/apps/core-front/e2e/screen-catalog/specs/__screenshots__/my-joined--ended--desktop.png b/frontend/apps/core-front/e2e/screen-catalog/specs/__screenshots__/my-joined--ended--desktop.png index d35e4d784..d3cdbfa22 100644 Binary files a/frontend/apps/core-front/e2e/screen-catalog/specs/__screenshots__/my-joined--ended--desktop.png and b/frontend/apps/core-front/e2e/screen-catalog/specs/__screenshots__/my-joined--ended--desktop.png differ diff --git a/frontend/apps/core-front/e2e/specs/joined-studies.spec.ts b/frontend/apps/core-front/e2e/specs/joined-studies.spec.ts index 13b1dd54b..77d248545 100644 --- a/frontend/apps/core-front/e2e/specs/joined-studies.spec.ts +++ b/frontend/apps/core-front/e2e/specs/joined-studies.spec.ts @@ -4,7 +4,7 @@ import { expect, test } from '@playwright/test'; const DAY = 24 * 60 * 60 * 1000; const at = (offsetDays: number) => new Date(Date.now() + offsetDays * DAY).toISOString(); -/** GET /api/me/studies 고정 응답 — 참여중 1건 · 완주 1건. 백엔드 없이 화면을 본다. */ +/** GET /api/me/studies 고정 응답 — 참여중 1건 · 완주 1건 · 완료 1건. 백엔드 없이 화면을 본다. */ const MY_STUDIES = { items: [ { @@ -39,18 +39,44 @@ const MY_STUDIES = { startAt: at(-90), endAt: at(-30), relation: 'COMPLETED', + finished: true, participantStatus: 'COMPLETED', participantRole: 'MEMBER', captain: false, discordChannelUrl: null, driveUrl: null, - attendanceRate: 0.5, + attendanceRate: 0.75, meetings: [-60, -45].map((d, i) => ({ meetingId: 2000 + i, sequence: i + 1, scheduledAt: at(d), startAt: null, endAt: null, + attendanceStatus: i === 0 ? 'PRESENT' : 'LATE', + countedInRate: true, + })), + }, + { + studyId: 103, + title: 'E2E 완료 스터디', + category: 'BACKEND', + studyKind: 'STUDY', + startAt: at(-80), + endAt: at(-20), + relation: 'COMPLETED', + finished: false, + participantStatus: 'COMPLETED', + participantRole: 'MEMBER', + captain: false, + discordChannelUrl: null, + driveUrl: null, + attendanceRate: 0.5, + meetings: [-50, -35].map((d, i) => ({ + meetingId: 3000 + i, + sequence: i + 1, + scheduledAt: at(d), + startAt: null, + endAt: null, attendanceStatus: i === 0 ? 'PRESENT' : 'ABSENT', countedInRate: true, })), @@ -155,8 +181,21 @@ test.describe('내 스터디 (crew-joined-studies) — 기본 화면 및 인터 await page.getByRole('tab', { name: '참여 종료' }).click(); await expect(page.getByRole('tab', { name: '참여 종료' })).toHaveAttribute('aria-selected', 'true'); - // 완주 점수판("완주를 축하합니다!") 노출 확인 - await expect(page.getByText(/완주를 축하합니다!/).first()).toBeVisible(); + // 완주 카드만 점수판("완주를 축하합니다!")을 받고, 결석이 있는 완료 카드는 「완료」 배지만 받는다 + const endedCards = page.getByRole('listitem').filter({ hasText: /완주|완료|종료/ }); + await expect(endedCards.filter({ hasText: '완주를 축하합니다!' }).first()).toBeVisible(); + const completedCard = endedCards.filter({ has: page.getByText('완료', { exact: true }) }).first(); + await expect(completedCard).toBeVisible(); + await expect(completedCard).not.toContainText('완주'); + // 참여 종료 탭은 완주 카드를 모두 완료 카드보다 먼저 둔다 + const kinds: string[] = []; + for (let i = 0; i < (await endedCards.count()); i++) { + const card = endedCards.nth(i); + if ((await card.getByText('완주를 축하합니다!').count()) > 0) kinds.push('finished'); + else if ((await card.getByText('완료', { exact: true }).count()) > 0) kinds.push('completed'); + } + expect(kinds.indexOf('completed')).toBeGreaterThan(-1); + expect(kinds.lastIndexOf('finished')).toBeLessThan(kinds.indexOf('completed')); // 3. 전체 탭 await page.getByRole('tab', { name: '전체' }).click(); diff --git a/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.feature b/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.feature index fd2ee782a..b11bec72d 100644 --- a/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.feature +++ b/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.feature @@ -42,13 +42,14 @@ Feature: 내 스터디 — 크루 참여 스터디 모음 (crew-joined-studies) Then 시작 전 스터디 카드만 목록에 남고 정렬은 "다음 회차 순"으로 유지된다 When "참여 종료" 탭을 클릭한다 Then 참여가 종료된 스터디 카드만 남고 정렬이 "종료일 최근 순"으로 자동 전환된다 - And 완주한 스터디 카드가 참여 중단 스터디보다 상단에 우선 배치된다 + And 완주한 스터디 카드가 완료 · 참여 중단 스터디보다 상단에 우선 배치된다 When "전체" 탭을 클릭한다 Then 모든 참여 스터디가 표시된다 - Scenario: 참여 종료 탭에서 완주 카드와 참여 중단 카드 구분 + Scenario: 참여 종료 탭에서 완주 · 완료 · 참여 중단 카드 구분 Given "참여 종료" 탭이 선택되어 있다 Then 완주 스터디 카드는 골드/앰버 테두리와 "완주" 배지, 완주 점수판("완주를 축하합니다!")이 표시된다 + And 결석이 있어 완주하지 못한 완료 카드는 회색 "완료" 배지와 "다음 일정 없음" 문구가 표시되고, 메달 · 점수판 없이 스터디 일정으로 이동한다 And 참여 중단(withdrawn) 카드는 회색 "종료" 배지와 "다음 일정 없음" 문구가 표시되며 클릭할 수 없다 Scenario: 역할 드롭다운 필터링 diff --git a/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.meta.ts b/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.meta.ts index 885d22291..c2bd25363 100644 --- a/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.meta.ts +++ b/frontend/apps/core-front/screen-catalog/features/my/joinedStudies.meta.ts @@ -33,10 +33,10 @@ export const joinedStudiesScreenStates: ScreenStateDef[] = [ { id: 'my-joined--ended', prdScenarios: ['CORE-ST-009-S05'], - label: '내 스터디 — 참여 종료 탭 (완주 카드 & 종료 카드)', + label: '내 스터디 — 참여 종료 탭 (완주 · 완료 · 종료 카드)', pageId: 'my-joined', rationale: - '참여 종료 탭 선택 시 완주 카드(완주 점수판, 앰버 스타일)와 참여 중단 카드가 올바르게 구분되어 렌더링되는지 확인한다.', + '참여 종료 탭 선택 시 완주 카드(완주 점수판, 앰버 스타일), 결석이 있어 완주하지 못한 완료 카드(회색 「완료」 배지)와 참여 중단 카드가 올바르게 구분되어 렌더링되는지 확인한다.', recipe: { storage: [ { diff --git a/frontend/apps/core-front/screen-catalog/features/prd/crew-joined-studies.feature b/frontend/apps/core-front/screen-catalog/features/prd/crew-joined-studies.feature index 0aafe394a..881c5c0e3 100644 --- a/frontend/apps/core-front/screen-catalog/features/prd/crew-joined-studies.feature +++ b/frontend/apps/core-front/screen-catalog/features/prd/crew-joined-studies.feature @@ -7,7 +7,7 @@ Feature: ST-009 크루는 참여 중인 스터디를 모아 볼 수 있다. @CORE-ST-009-S01 @catalog-partial Scenario: CORE-ST-009-S01 완료 기준 1 Given PRD의 권한·데이터·응답 조건과 해당 완료 기준의 경계 조건이 준비되어 있다 - When 참여중·완주·중단 스터디가 있는 내 스터디를 연다 + When 참여중·완주·완료·중단 스터디가 있는 내 스터디를 연다 Then 목록에 참여 상태별 스터디가 보임 # 부분 실행 근거: my-joined--default @@ -35,7 +35,7 @@ Feature: ST-009 크루는 참여 중인 스터디를 모아 볼 수 있다. Scenario: CORE-ST-009-S05 완료 기준 5 Given PRD의 권한·데이터·응답 조건과 해당 완료 기준의 경계 조건이 준비되어 있다 When 참여 종료 탭을 연다 - Then 완주와 참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 + Then 완주·완료·참여 중단이 같은 탭에 모이되, 카드에서 완주만 따로 구분됨 # 부분 실행 근거: my-joined--ended @CORE-ST-009-S06 diff --git a/frontend/apps/core-front/src/app/[locale]/my/joined/page.tsx b/frontend/apps/core-front/src/app/[locale]/my/joined/page.tsx index 740e6d80b..977f99996 100644 --- a/frontend/apps/core-front/src/app/[locale]/my/joined/page.tsx +++ b/frontend/apps/core-front/src/app/[locale]/my/joined/page.tsx @@ -15,12 +15,14 @@ import { getUser } from '@/features/auth/auth'; import { IS_DEV, syncPreview } from '@/features/auth/preview'; import { StudyFeedbackButton } from '@/features/feedback/StudyFeedbackButton'; import { + COMPLETED_BADGE, LEFT_BADGE, LIFE_LABEL, SCHEDULE_ROLE_LABEL, addDays, durationOf, isCompleted, + isFinished, lifeStatus, mondayOf, upcomingMeeting, @@ -127,7 +129,7 @@ function studiesIn( return t(a.title, locale).localeCompare(t(b.title, locale), locale); }; return [...list].sort( - (a, b) => (filter === 'ended' ? Number(isCompleted(b)) - Number(isCompleted(a)) : 0) || byKey(a, b), + (a, b) => (filter === 'ended' ? Number(isFinished(b)) - Number(isFinished(a)) : 0) || byKey(a, b), ); } @@ -262,13 +264,18 @@ function MissionClear({ book }: { book: MyAttendanceBook }) { function StudyItem({ study, locale, wallTz }: { study: JoinedStudy; locale: Locale; wallTz: WallTz }) { const { icon: Icon } = categoryMeta(study.category); const life = lifeStatus(study); - const completed = isCompleted(study); - const left = life === 'ended' && !completed; + const finished = isFinished(study); + const left = life === 'ended' && !isCompleted(study); const book = myAttendanceBook(study); // 이 스터디에서 내 역할 — 서버의 participantRole·captain 이 정한다 const role = study.role; // 카드는 스터디 일정으로 간다. 참여를 중단한 스터디는 더 이상 참가자가 아니라 링크가 없다. - const linked = !(life === 'ended' && !completed); + const linked = !left; + const badge = left + ? LEFT_BADGE + : isCompleted(study) + ? COMPLETED_BADGE + : { label: LIFE_LABEL[life], tone: LIFE_TONE[life] }; return (

  • @@ -277,17 +284,17 @@ function StudyItem({ study, locale, wallTz }: { study: JoinedStudy; locale: Loca className={cx( 'relative flex gap-4 overflow-hidden', linked && 'cursor-pointer transition-colors hover:border-border-strong hover:bg-surface-1', - completed && 'border-warning-400 bg-warning-50 shadow-sm', + finished && 'border-warning-400 bg-warning-50 shadow-sm', )} > - {completed &&