perf: OTC API 최적화 및 뱃지 안정화

- N+1 쿼리 → JOIN 한방 쿼리로 개선
  - 21번 쿼리 → 1번 쿼리
  - 2.4초 → 37ms (20건 조회 기준)
- DB warmup 추가 (앱 시작 시 연결 미리 생성)
- OTC 뱃지 insertBefore 방식으로 변경 (레이아웃 안정화)
- 중복 뱃지 방지 로직 추가
This commit is contained in:
thug0bin
2026-03-05 20:32:00 +09:00
parent 69b75d6724
commit 636fd66f9e
2 changed files with 76 additions and 63 deletions

View File

@@ -1880,10 +1880,15 @@
if (data.success && data.count > 0) {
otcData = data;
// OTC 뱃지 추가 (질병 뱃지 앞에)
// OTC 뱃지 추가 ( 앞에)
const rxInfo = document.getElementById('rxInfo');
const otcBadge = `<span class="otc-badge" onclick="showOtcModal()">💊 OTC ${data.count}</span>`;
rxInfo.innerHTML = otcBadge + rxInfo.innerHTML;
if (rxInfo && !rxInfo.querySelector('.otc-badge')) {
const otcBadge = document.createElement('span');
otcBadge.className = 'otc-badge';
otcBadge.onclick = showOtcModal;
otcBadge.innerHTML = `💊 OTC ${data.count}`;
rxInfo.insertBefore(otcBadge, rxInfo.firstChild);
}
} else {
otcData = null;
}