修复bug
This commit is contained in:
44
test_analytics.py
Normal file
44
test_analytics.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
测试数据分析功能
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from src.flask_prompt_master import create_app, db
|
||||
from src.flask_prompt_master.admin.views.analytics_admin import AnalyticsAdminView
|
||||
from src.flask_prompt_master.models.models import User, Prompt, PromptTemplate
|
||||
from sqlalchemy import func, case
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def test_analytics():
|
||||
"""测试数据分析功能"""
|
||||
app = create_app()
|
||||
|
||||
with app.app_context():
|
||||
print("=" * 60)
|
||||
print("测试数据分析功能")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
# 创建AnalyticsAdminView实例
|
||||
analytics_view = AnalyticsAdminView()
|
||||
|
||||
# 测试获取分析数据
|
||||
print("🔍 测试获取分析数据...")
|
||||
stats = analytics_view._get_analytics_data()
|
||||
|
||||
print("✅ 数据分析功能正常")
|
||||
print("\n📊 统计数据:")
|
||||
for key, value in stats.items():
|
||||
print(" {}: {}".format(key, value))
|
||||
|
||||
except Exception as e:
|
||||
print("❌ 数据分析功能测试失败: {}".format(str(e)))
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_analytics()
|
||||
Reference in New Issue
Block a user