feat: /api/meta/coverage — 데이터 커버리지 요약 (#21) #28

Merged
xhh merged 1 commit from issue-21-meta-coverage into main 2026-04-22 02:55:41 +09:00
Owner

요약

운영 대시보드(#22) 의 "현재 어떤 데이터가 수집되어 있는가" 섹션용 요약 API.

응답

  • tables.<name>: total_rows, unique_symbols, symbols[{symbol, min_date, max_date, count}]
  • gaps.defined_but_missing: indicators.yaml 정의 대비 DB 누락 심볼
  • gaps.stale + stale_days: N일 이상 정체된 심볼
  • as_of: 요청 시각

쿼리

  • ?brief=true (symbols 상세 생략)
  • ?stale_days=7 (1~365)

특이 케이스

  • margin_debt 는 단일 시리즈 → symbol 을 테이블명으로 정규화
  • insider_trades 는 ticker/filing_date 컬럼 사용

테스트 6건

TDD 관례대로 empty/seeded/brief/gaps-missing/gaps-stale/margin-single 검증.

로컬 uv run pytest30 passed.

Closes #21

## 요약 운영 대시보드(#22) 의 "현재 어떤 데이터가 수집되어 있는가" 섹션용 요약 API. ## 응답 - `tables.<name>`: total_rows, unique_symbols, symbols[{symbol, min_date, max_date, count}] - `gaps.defined_but_missing`: indicators.yaml 정의 대비 DB 누락 심볼 - `gaps.stale` + `stale_days`: N일 이상 정체된 심볼 - `as_of`: 요청 시각 ## 쿼리 - `?brief=true` (symbols 상세 생략) - `?stale_days=7` (1~365) ## 특이 케이스 - margin_debt 는 단일 시리즈 → symbol 을 테이블명으로 정규화 - insider_trades 는 ticker/filing_date 컬럼 사용 ## 테스트 6건 TDD 관례대로 empty/seeded/brief/gaps-missing/gaps-stale/margin-single 검증. 로컬 `uv run pytest` → **30 passed**. Closes #21
/api/meta/coverage — 데이터 커버리지 요약 + gaps 분석 (#21)
All checks were successful
Tests (PR) / pytest (pull_request) Successful in 25s
8943af2a53
운영 대시보드(#22) 의 "현재 어떤 데이터가 수집되어 있는가" 섹션이 소비할 요약 API. 5개 테이블의 심볼별 min/max/count 와 indicators.yaml 대비 누락 심볼/오래 안 업데이트된 심볼을 반환.

## 동작

- **tables**: economic_indicators / equity_prices / crypto_prices / insider_trades / margin_debt 각각에 대해
  - total_rows, unique_symbols
  - symbols: [{symbol, min_date, max_date, count}] (brief=true 면 null)
- **gaps.defined_but_missing**: indicators.yaml 에 정의됐으나 DB 에 한 번도 없는 심볼
- **gaps.stale** (+ stale_days): max_date 가 N일 이상 전인 심볼
- **as_of**: 요청 시각

## 쿼리 파라미터
- `?brief=true`  — symbols 상세 생략 (헤드라인만)
- `?stale_days=7` — stale 기준 (기본 7, 1~365)

## 특이 케이스
- margin_debt 는 단일 시리즈라 심볼 컬럼 없음. symbol 을 테이블명("margin_debt")으로 정규화.
- insider_trades 는 ticker / filing_date 를 심볼·날짜 컬럼으로 사용.

## 테스트 (6 case, TDD)
- test_empty_coverage: 빈 DB 에서 defined_but_missing 에 yaml 정의 심볼 모두 포함
- test_coverage_counts_and_min_max: SPY 3건/QQQ 1건 시드 후 정확한 집계
- test_brief_omits_symbols: brief 모드에서 symbols=null
- test_gaps_defined_but_missing_excludes_observed: DB 에 있는 심볼은 missing 제외
- test_gaps_stale_over_N_days: 10일 전 데이터는 stale(7일 기준), 1일 전은 제외
- test_margin_debt_single_series_coverage: margin_debt 가 단일 행으로 집계

로컬 uv run pytest -> 30 passed (smoke 3 + watchlist 10 + reports 11 + coverage 6).

Closes #21

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xhh merged commit d7d4b55536 into main 2026-04-22 02:55:41 +09:00
xhh referenced this pull request from a commit 2026-04-22 02:55:42 +09:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xhh/financial-data-platform!28
No description provided.