feat: 어드민 집계 페이지에 반려동물 통계 추가

통계 카드:
- 등록 반려동물 총 수
- 강아지/고양이 종류별 수
- 노란색 그라데이션 카드 스타일

최근 등록 반려동물 섹션:
- 최근 10마리 반려동물 카드
- 사진 + 이름 + 품종 + 보호자 정보
- 보호자 전화번호 마스킹 처리
This commit is contained in:
thug0bin
2026-03-02 16:37:25 +09:00
parent a7b3d5b7e0
commit c525632246
2 changed files with 68 additions and 1 deletions

View File

@@ -2208,6 +2208,35 @@ def admin():
FROM claim_tokens
""")
token_stats = cursor.fetchone()
# 반려동물 통계
cursor.execute("""
SELECT
COUNT(*) as total_pets,
SUM(CASE WHEN species = 'dog' THEN 1 ELSE 0 END) as dog_count,
SUM(CASE WHEN species = 'cat' THEN 1 ELSE 0 END) as cat_count,
COUNT(DISTINCT user_id) as owners_count
FROM pets
WHERE is_active = 1
""")
pet_stats = cursor.fetchone()
# 최근 등록 반려동물 (10마리)
cursor.execute("""
SELECT p.id, p.name, p.species, p.breed, p.photo_url, p.created_at,
u.nickname as owner_name, u.phone as owner_phone
FROM pets p
JOIN users u ON p.user_id = u.id
WHERE p.is_active = 1
ORDER BY p.created_at DESC
LIMIT 10
""")
recent_pets_raw = cursor.fetchall()
recent_pets = []
for pet in recent_pets_raw:
pet_dict = dict(pet)
pet_dict['created_at'] = utc_to_kst_str(pet['created_at'])
recent_pets.append(pet_dict)
# 최근 QR 발행 내역 (20건)
cursor.execute("""
@@ -2237,7 +2266,9 @@ def admin():
recent_users=recent_users,
recent_transactions=recent_transactions,
token_stats=token_stats,
recent_tokens=recent_tokens)
recent_tokens=recent_tokens,
pet_stats=pet_stats,
recent_pets=recent_pets)
# ============================================================================