부모 티켓
2개 티켓

백로그

0
티켓 없음

할 일

0
티켓 없음

진행 중

0
티켓 없음

리뷰

0
티켓 없음

완료 (15일)

2
높음 6625f49d
서브 티켓 [P1-COORD] 마무리 (성경 통독 + 묵상 통계)

성경 통독 현황 (BibleReadingLog + 66권 시각화)

## 목표 BibleReadingLog 모델 생성 + 성경 66권 통독 현황 시각화 페이지 구현 ## 모델 ### BibleReadingLog - user_id: UUID FK NOT NULL - book_name: string NOT NULL (한국어 책명: "창세기", "출애굽기" 등) - chapter: integer NOT NULL - read_date: date NOT NULL - INDEX: (user_id, book_name, chapter, read_date) - 같은 장 같은 날짜 중복 허용 (여러 번 읽기 가능) ## 성경 데이터 유틸리티 ### lib/bible_data.rb (모듈) - BIBLE_BOOKS 상수: 구약 39권 + 신약 27권 데이터 - 각 책: { name: "창세기", abbrev: "창", chapters: 50, testament: :old } - 총 1189장 - OLD_TESTAMENT, NEW_TESTAMENT 상수 - TOTAL_CHAPTERS = 1189 - 책명으로 장수 조회 메서드 ## 컨트롤러 ### TongtokController - index: 통독 현황 페이지 - params[:year] (기본 올해) - BibleReadingLog에서 해당 연도 데이터 집계 - { "창세기" => { 1 => 2, 2 => 1 }, ... } 형태로 책별/장별 읽기 횟수 - 전체 진행률 계산 (읽은 고유 장 수 / 1189 * 100) ### BibleReadingsController - create: 통독 기록 저장 - params: { bible_reading: { book_name:, chapter:, read_date: } } - 또는 배치: { chapters: [{ book_name:, chapter: }] } (같은 날짜) - destroy: 통독 기록 삭제 ## 뷰 ### tongtok/index.html.erb - 제목: "성경 통독 현황" - 연도 선택 드롭다운 - 전체 진행률 표시 (N / 1189장, N%) - 구약 / 신약 탭 - 각 책을 카드로 표시: - 책이름 + 읽은 장/전체 장 - 장별 그리드 (읽은 횟수에 따라 색상 변화: 0=회색, 1=연초록, 2+=진초록) - 장 클릭 시 읽기 기록 생성/삭제 토글 (Turbo Stream) - data-testid="tongtok-book" (각 책 카드), data-testid="progress-bar" (진행률) - 기존 shared 파셜 활용 (card, badge, tabs, progress) ## 라우트 (routes.rb는 수정하지 마세요! stats-dev가 관리합니다) - 필요한 라우트를 팀리드에게 SendMessage로 전달하면 stats-dev가 추가합니다 - 예상 라우트: ```ruby get "tongtok", to: "tongtok#index" resources :bible_readings, only: [:create, :destroy] ``` ## 테스트 - 모델 테스트: BibleReadingLog validations, associations - 컨트롤러 테스트: TongtokController (index, 진행률), BibleReadingsController (create, destroy) - lib/bible_data 테스트 (optional) ## 파일 담당 (다른 에이전트 파일 수정 금지) - 수정 가능: app/models/bible_reading_log.rb, app/models/user.rb (has_many 추가), db/migrate/*, app/controllers/tongtok_controller.rb, app/controllers/bible_readings_controller.rb, app/views/tongtok/*, lib/bible_data.rb, test/* - 수정 금지: config/routes.rb, app/controllers/stats_controller.rb, app/controllers/records_controller.rb

T
tongtok-dev
9 days
높음 d3fcfb29
서브 티켓 [P1-COORD] 마무리 (성경 통독 + 묵상 통계)

묵상 통계/히스토리 + routes.rb 관리

## 목표 묵상 통계 대시보드 + 묵상 히스토리 목록 + routes.rb 통합 관리 ## routes.rb 관리 (최우선!) 이 티켓의 에이전트가 routes.rb 유일한 관리자입니다. 아래 라우트를 모두 추가하세요: ```ruby # Tongtok (tongtok-dev가 구현) get "tongtok", to: "tongtok#index", as: :tongtok resources :bible_readings, only: [:create, :destroy] # Stats & Records get "stats", to: "stats#show", as: :stats get "records", to: "records#index", as: :records ``` ## 컨트롤러 ### StatsController - show: 묵상 통계 대시보드 - params[:year] (기본 올해) - UserMeditation 기반 통계 계산: - 총 묵상 수 (count) - 완료 묵상 수 (personal_meditation 또는 action_plan이 존재하는 것) - 완료율 (%) - 평균 기분 (mood_after 평균, 1-5) - 연속 묵상일수 (current_streak: 오늘부터 거슬러 올라가며 연속된 날 수) - 최대 연속일수 (max_streak) - 월별 묵상 수 배열 (1-12월) - @stats 해시로 뷰에 전달 ### RecordsController - index: 묵상 기록 목록 - params[:page] (기본 1), params[:month] (YYYY-MM 형태) - current_user.user_meditations.includes(:qt_content).order(meditation_date: :desc) - 페이지네이션 (10개/페이지) - 월별 필터 ## 통계 계산 로직 (StatsHelper 또는 concern) ### 연속일수 (Streak) 계산 ```ruby # current_streak: 오늘(또는 가장 최근 묵상일)부터 연속된 날 수 dates = user.user_meditations.where(meditation_date: year_range).pluck(:meditation_date).uniq.sort.reverse streak = 0 expected = Date.current dates.each do |d| break unless d == expected streak += 1 expected -= 1.day end # max_streak: 전체 기간 중 최대 연속 ``` ### 완료 판단 ```ruby # personal_meditation 또는 action_plan 중 하나에 내용이 있으면 완료 scope :completed, -> { where("personal_meditation IS NOT NULL AND personal_meditation != '' OR action_plan IS NOT NULL AND action_plan != ''") } ``` ## 뷰 ### stats/show.html.erb - 제목: "묵상 통계" (h1) - 연도 선택 - 핵심 지표 카드 4개: 총 묵상, 완료율, 연속일수, 평균 기분 - 월별 묵상 차트 (bar chart - 순수 HTML/CSS 또는 SVG 바 차트) - 외부 JS 라이브러리 사용 하지 마세요. 순수 Tailwind CSS로 바 차트 구현: ```erb <div class="flex items-end gap-1 h-40"> <% @stats[:monthly_data].each_with_index do |count, i| %> <div class="flex-1 bg-brand-primary rounded-t" style="height: <%= count > 0 ? [count.to_f / max * 100, 5].max : 0 %>%" title="<%= i+1 %>월: <%= count %>회"> </div> <% end %> </div> ``` - data-testid="stat-card" (각 지표 카드) - data-testid="monthly-chart" (월별 차트) ### records/index.html.erb - 제목: "묵상 기록" (h1) - 월별 필터 (month input) - 기록 목록: 날짜, 성경구절, 묵상 내용 미리보기, 기분 이모지 - 페이지네이션 (이전/다음) - 빈 상태 처리 - data-testid="record-item" (각 기록) ## 테스트 - 컨트롤러 테스트: StatsController (show, 통계값 검증), RecordsController (index, 페이지네이션, 필터) - 연속일수 계산 정확성 검증 ## Fixtures - 기존 user_meditations.yml에 테스트용 데이터가 있으면 활용 - 없으면 stats 테스트용 fixture 추가 (연속일수 테스트를 위해 여러 날짜의 묵상) ## 파일 담당 (다른 에이전트 파일 수정 금지) - 수정 가능: config/routes.rb, app/controllers/stats_controller.rb, app/controllers/records_controller.rb, app/views/stats/*, app/views/records/*, test/*, app/models/user_meditation.rb (scope 추가) - 수정 금지: app/models/bible_reading_log.rb, app/controllers/tongtok_controller.rb, app/controllers/bible_readings_controller.rb, app/views/tongtok/*

S
stats-dev
9 days