4th_fix time error
This commit is contained in:
@@ -18,6 +18,7 @@ from app.utils.logger import get_logger
|
||||
from app.models.user import User
|
||||
from app.models.job import TranslationJob
|
||||
from app.models.stats import APIUsageStats
|
||||
from app.utils.timezone import format_taiwan_time
|
||||
from app.models.log import SystemLog
|
||||
from app.models.cache import TranslationCache
|
||||
from sqlalchemy import func, desc
|
||||
@@ -75,8 +76,8 @@ def get_system_stats():
|
||||
'daily_stats': daily_stats,
|
||||
'user_rankings': user_rankings_data,
|
||||
'period': 'month',
|
||||
'start_date': datetime.utcnow().isoformat(),
|
||||
'end_date': datetime.utcnow().isoformat()
|
||||
'start_date': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'end_date': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S")
|
||||
}
|
||||
))
|
||||
|
||||
@@ -359,7 +360,7 @@ def get_system_health():
|
||||
try:
|
||||
from datetime import datetime
|
||||
status = {
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'status': 'healthy',
|
||||
'services': {}
|
||||
}
|
||||
@@ -400,7 +401,7 @@ def get_system_health():
|
||||
except Exception as e:
|
||||
logger.error(f"Get system health error: {str(e)}")
|
||||
return jsonify({
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
@@ -434,7 +435,7 @@ def get_system_metrics():
|
||||
recent_counts = {status: count for status, count in recent_jobs}
|
||||
|
||||
metrics_data = {
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'jobs': {
|
||||
'pending': job_counts.get('PENDING', 0),
|
||||
'processing': job_counts.get('PROCESSING', 0),
|
||||
|
@@ -13,6 +13,7 @@ from flask import Blueprint, jsonify
|
||||
from app.utils.helpers import create_response
|
||||
from app.utils.logger import get_logger
|
||||
from app.models.job import TranslationJob
|
||||
from app.utils.timezone import format_taiwan_time, now_taiwan
|
||||
|
||||
health_bp = Blueprint('health', __name__, url_prefix='/health')
|
||||
logger = get_logger(__name__)
|
||||
@@ -23,7 +24,7 @@ def health_check():
|
||||
"""系統健康檢查"""
|
||||
try:
|
||||
status = {
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'status': 'healthy',
|
||||
'services': {}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ def health_check():
|
||||
except Exception as e:
|
||||
logger.error(f"Health check error: {str(e)}")
|
||||
return jsonify({
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
@@ -131,7 +132,7 @@ def get_metrics():
|
||||
|
||||
# 系統指標
|
||||
metrics_data = {
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'jobs': {
|
||||
'pending': job_counts.get('PENDING', 0),
|
||||
'processing': job_counts.get('PROCESSING', 0),
|
||||
@@ -217,6 +218,6 @@ def ping():
|
||||
"""簡單的 ping 檢查"""
|
||||
return jsonify({
|
||||
'status': 'ok',
|
||||
'timestamp': datetime.utcnow().isoformat(),
|
||||
'timestamp': format_taiwan_time(datetime.utcnow(), "%Y-%m-%d %H:%M:%S"),
|
||||
'message': 'pong'
|
||||
})
|
Reference in New Issue
Block a user