perf(travel-proxy): 배치 DB 연결 + nginx sync timeout 600s

- db.py: batch_sync_album, batch_mark_thumbs_done 추가
- indexer.py: 앨범 단위 배치 동기화로 전환
- nginx: /api/travel/ proxy_read_timeout 600s 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-24 09:15:21 +09:00
parent 7011d3ef3a
commit cb6e2d992a
3 changed files with 67 additions and 12 deletions

View File

@@ -92,7 +92,7 @@ def sync(
elif isinstance(v, dict) and isinstance(v.get("albums"), list):
all_albums.update(v["albums"])
# 2. 각 앨범 폴더 스캔 → DB 동기화
# 2. 각 앨범 폴더 스캔 → DB 배치 동기화
added = 0
updated = 0
removed = 0
@@ -100,29 +100,27 @@ def sync(
for album in sorted(all_albums):
folder = travel_root / album
items = _scan_folder(folder)
existing_filenames = set()
existing_filenames = {item["filename"] for item in items}
for item in items:
existing_filenames.add(item["filename"])
result = db.upsert_photo(album, item["filename"], item["mtime"])
if result == "added":
added += 1
elif result == "updated":
updated += 1
removed += db.remove_missing_photos(album, existing_filenames)
result = db.batch_sync_album(album, items, existing_filenames)
added += result["added"]
updated += result["updated"]
removed += result["removed"]
# 3. 썸네일 미생성 분 일괄 생성
no_thumb = db.get_photos_without_thumb()
thumbs_generated = 0
thumb_done_batch = []
for photo in no_thumb:
src = travel_root / photo["album"] / photo["filename"]
dest = thumb_root / photo["album"] / photo["filename"]
if _generate_thumb(src, dest):
db.mark_thumb_done(photo["album"], photo["filename"])
thumb_done_batch.append(photo)
thumbs_generated += 1
db.batch_mark_thumbs_done(thumb_done_batch)
duration = round(time.time() - start, 2)
logger.info(
"Sync complete: added=%d updated=%d removed=%d thumbs=%d duration=%.2fs",