| 호출 계층 | 실제 코드 (파일·함수) | 하는 일 |
|---|---|---|
| Chrome 확장 | gitFolio/background/background.js → analyzeRepository() |
① 팝업/사이드패널에서 입력 받은 owner / repo / username / count를 JSON으로 묶어② 백엔드 POST /overview/api/generate/ 로 전송 |
| Django 뷰 | overview/views.py → generate_overview_api(request) |
1) JSON 파싱2) fetch_detailed_commit_history(owner, repo, username, count, save_to_db=True) 호출 (→ GitHub) |
| GitHub 수집 로직 | overview/utils.py → fetch_detailed_commit_history() |
- GraphQL https://api.github.com/graphql 로 최대 count*3개 커밋 가져옴- Python에서 author 필터(username) 후 filtered_commits 생성- save_to_db=True 이므로 바로 save_commits_to_db() 실행 |
🔑 API 종류
- 커밋 목록: GraphQL
history(first: …)- 커밋 파일 상세(새 커밋일 때만): REST
GET /repos/{owner}/{repo}/commits/{sha}→fetch_and_save_commit_files()
| 모델(테이블) | 저장 함수 | 주요 컬럼 |
|---|---|---|
overview_repository |
save_commits_to_db() (get_or_create) |
owner, name |
overview_commit |
동일 함수 (get_or_create) |
sha, author, message, committed_date, additions, deletions, changed_files, repository_id(FK) |
overview_commitfile |
fetch_and_save_commit_files() |
filename, status, additions, deletions, commit_id(FK) |
overview_commitanalysis |
analyze_commit_messages() 내부 update_or_create |
username, commit_count, analysis_json, repository_id(FK) |
overview/utils.py → analyze_commit_messages(commits, …)
python
commit_messages = "\\n".join(
f"{c['messageHeadline']} ({c['committedDate']})" for c in commits
)
analysis_json = call_anthropic_api(commit_messages, …) # Claude 3 Sonnet
CommitAnalysis 행으로 영구 저장.(owner, repo, username) 조합이면 DB 분석 캐시를 바로 반환(API 재호출 X).overview/views.py → commit_list_api(request)
DB 우선 조회: get_stored_commits()
결과가 없을 때만 fetch_detailed_commit_history(save_to_db=False) 로 GitHub 재조회 → JSON 반환.
(따라서 이미 저장돼 있으면 네트워크 트래픽 없이 DB 직렬화 결과를 팝업에 뿌림.)
overview/views.py → commit_detail_api(request, sha)
Commit + CommitFile 로부터 상세 JSON을 직렬화.