Skip to content

feat: add /studies and /members commands with code quality fixes#8

Merged
songkg7 merged 16 commits intoLearning-Is-Vital-In-Development:mainfrom
songkg7:study-command
Mar 2, 2026
Merged

feat: add /studies and /members commands with code quality fixes#8
songkg7 merged 16 commits intoLearning-Is-Vital-In-Development:mainfrom
songkg7:study-command

Conversation

@songkg7
Copy link
Member

@songkg7 songkg7 commented Mar 1, 2026

Summary

  • /studies 커맨드 추가: 분기/상태별 스터디 목록 조회 (관리자 전용, ephemeral)
  • /members 커맨드 추가: 스터디별 활성 멤버 목록 조회 (전체 멤버 사용 가능, ephemeral + autocomplete)
  • 코드 리뷰 지적 사항 수정 (CRITICAL/HIGH/MEDIUM)

변경 사항

/studies 커맨드

  • branch, status 옵션으로 필터링 (기본값: status=active)
  • FindByFilters DB 메서드 추가
  • docker-compose 환경변수 매핑 수정 (POSTGRES_* → 컨테이너 내부 설정 일치)

/members 커맨드

  • channel autocomplete로 active 스터디 선택
  • FindActiveByStudyID DB 메서드 추가 (left_at IS NULL 필터)
  • 응답: 📚 **studyName** members (N) + <@userID> (joined: YYYY-MM-DD)
  • DefaultMemberPermissions 없음 → 모든 멤버 사용 가능

코드 품질 수정

  • CRITICAL: archive_category.go off-by-one 오류 수정 (50채널 제한 계산)
  • HIGH: respondArchiveAutocompleterespondAutocomplete로 통합 (helpers.go)
  • HIGH: submit 핸들러 에러 로깅 중복 제거
  • MEDIUM: branch 검증 함수명 개선, 방어적 nil 체크, 테이블 드리븐 테스트 적용

수정 파일 (20개)

파일 변경
bot/commands.go /studies, /members 정의 추가
bot/handler_studies.go 신규 — 핸들러 + 응답 빌더
bot/handler_studies_test.go 신규 — 테스트
bot/handler_members.go 신규 — 핸들러 + autocomplete + 응답 빌더
bot/handler_members_test.go 신규 — 테이블 드리븐 테스트
bot/bot.go 핸들러 등록
bot/helpers.go respondAutocomplete 통합, isValidBranch 추가
bot/handler_archive.go 중복 함수 제거, 공유 헬퍼 사용
db/study_repository.go FindByFilters, FindDistinctActiveBranches 추가
db/member_repository.go FindActiveByStudyID 추가
docker-compose.yml 환경변수 매핑 수정

Test plan

  • go build ./... 성공
  • go test ./... 전체 통과
  • /studies → 필터링 조회 확인
  • /studies status:archived → 아카이브 스터디 조회 확인
  • /members autocomplete → active 스터디 목록 표시 확인
  • /members 선택 → 멤버 목록 + 가입일 표시 확인 (ephemeral)
  • 멤버 없는 스터디 → "No members found" 메시지 확인

songkg7 added 4 commits March 1, 2026 22:42
- Fix nil dereference on i.Member in submit handler (CRITICAL)
- Replace log.Fatal with proper error return from bot.Run (CRITICAL)
- Add bot self-filter to OnReactionRemove (HIGH)
- Roll back Discord message on recruit DB save failure (HIGH)
- Add schema_migrations tracking to prevent re-running migrations (HIGH)
- Remove dead checkNilErr function
- Remove unnecessary HTTP GET in submit handler (body was unused)
- Handle TOCTOU race in ensureCategoryID with retry on create failure
- Use index-based access in getOrCreateWritableSlot to avoid stale pointer
- Sanitize channel names for Discord rules (lowercase, no special chars, 100 char limit)
- Validate required environment variables at startup with clear error messages
Allow any guild member to query the current participants of a study via
autocomplete channel selection. The response is ephemeral and shows each
member with their join date.

Also consolidates duplicate autocomplete responder into shared
respondAutocomplete helper in helpers.go.
Close recruitment for a branch, check member counts per study, and
either start (>= 3 members) or auto-archive (< 3 members) each study.
Extracts reusable archiveStudy function from archive handlers.
@songkg7 songkg7 merged commit 38d7f18 into Learning-Is-Vital-In-Development:main Mar 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant