feat: KIMS 상호작용 로그 뷰어 페이지 추가 (/admin/kims-logs)

This commit is contained in:
thug0bin
2026-02-28 13:38:47 +09:00
parent fbe7dde4ce
commit 16adca3646
2 changed files with 626 additions and 0 deletions

View File

@@ -4120,6 +4120,69 @@ def kill_process_on_port(port: int) -> bool:
# KIMS 약물 상호작용 API
# ═══════════════════════════════════════════════════════════
@app.route('/admin/kims-logs')
def admin_kims_logs():
"""KIMS 상호작용 로그 뷰어 페이지"""
return render_template('admin_kims_logs.html')
@app.route('/api/kims/logs')
def api_kims_logs():
"""KIMS 로그 목록 조회"""
from db.kims_logger import get_recent_logs
limit = int(request.args.get('limit', 100))
status = request.args.get('status', '')
interaction = request.args.get('interaction', '')
date = request.args.get('date', '')
try:
logs = get_recent_logs(limit=limit)
# 필터링
if status:
logs = [l for l in logs if l['api_status'] == status]
if interaction == 'has':
logs = [l for l in logs if l['interaction_count'] > 0]
elif interaction == 'severe':
logs = [l for l in logs if l['has_severe_interaction'] == 1]
elif interaction == 'none':
logs = [l for l in logs if l['interaction_count'] == 0]
if date:
logs = [l for l in logs if l['created_at'] and l['created_at'].startswith(date)]
return jsonify({'success': True, 'logs': logs})
except Exception as e:
return jsonify({'success': False, 'error': str(e)})
@app.route('/api/kims/logs/stats')
def api_kims_logs_stats():
"""KIMS 로그 통계"""
from db.kims_logger import get_stats
try:
stats = get_stats()
return jsonify({'success': True, 'stats': stats})
except Exception as e:
return jsonify({'success': False, 'error': str(e)})
@app.route('/api/kims/logs/<int:log_id>')
def api_kims_log_detail(log_id):
"""KIMS 로그 상세 조회"""
from db.kims_logger import get_log_detail
try:
log = get_log_detail(log_id)
if log:
return jsonify({'success': True, 'log': log})
else:
return jsonify({'success': False, 'error': '로그를 찾을 수 없습니다'}), 404
except Exception as e:
return jsonify({'success': False, 'error': str(e)})
@app.route('/api/kims/interaction-check', methods=['POST'])
def api_kims_interaction_check():
"""