Introduces a dedicated `HTMLReportGenerator` class in `report_generator.py` to handle all aspects of HTML and chart rendering. This decouples the report presentation logic from the data collection process within `StatisticOutputTask`. Key changes include: - Migrated all HTML and JavaScript generation into the new `HTMLReportGenerator`. - Extracted all statistic key constants into a separate `statistic_keys.py` file for improved organization. - Renamed `_generate_chart_data` to `_collect_chart_data` to better reflect its purpose. - Improved data handling robustness by using `.get()` for dictionary access and safely handling database query results.
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
该模块用于存放统计数据相关的常量键名。
|
|
"""
|
|
|
|
# 统计数据的键
|
|
TOTAL_REQ_CNT = "total_requests"
|
|
TOTAL_COST = "total_cost"
|
|
REQ_CNT_BY_TYPE = "requests_by_type"
|
|
REQ_CNT_BY_USER = "requests_by_user"
|
|
REQ_CNT_BY_MODEL = "requests_by_model"
|
|
REQ_CNT_BY_MODULE = "requests_by_module"
|
|
IN_TOK_BY_TYPE = "in_tokens_by_type"
|
|
IN_TOK_BY_USER = "in_tokens_by_user"
|
|
IN_TOK_BY_MODEL = "in_tokens_by_model"
|
|
IN_TOK_BY_MODULE = "in_tokens_by_module"
|
|
OUT_TOK_BY_TYPE = "out_tokens_by_type"
|
|
OUT_TOK_BY_USER = "out_tokens_by_user"
|
|
OUT_TOK_BY_MODEL = "out_tokens_by_model"
|
|
OUT_TOK_BY_MODULE = "out_tokens_by_module"
|
|
TOTAL_TOK_BY_TYPE = "tokens_by_type"
|
|
TOTAL_TOK_BY_USER = "tokens_by_user"
|
|
TOTAL_TOK_BY_MODEL = "tokens_by_model"
|
|
TOTAL_TOK_BY_MODULE = "tokens_by_module"
|
|
COST_BY_TYPE = "costs_by_type"
|
|
COST_BY_USER = "costs_by_user"
|
|
COST_BY_MODEL = "costs_by_model"
|
|
COST_BY_MODULE = "costs_by_module"
|
|
ONLINE_TIME = "online_time"
|
|
TOTAL_MSG_CNT = "total_messages"
|
|
MSG_CNT_BY_CHAT = "messages_by_chat"
|
|
TIME_COST_BY_TYPE = "time_costs_by_type"
|
|
TIME_COST_BY_USER = "time_costs_by_user"
|
|
TIME_COST_BY_MODEL = "time_costs_by_model"
|
|
TIME_COST_BY_MODULE = "time_costs_by_module"
|
|
AVG_TIME_COST_BY_TYPE = "avg_time_costs_by_type"
|
|
AVG_TIME_COST_BY_USER = "avg_time_costs_by_user"
|
|
AVG_TIME_COST_BY_MODEL = "avg_time_costs_by_model"
|
|
AVG_TIME_COST_BY_MODULE = "avg_time_costs_by_module"
|
|
STD_TIME_COST_BY_TYPE = "std_time_costs_by_type"
|
|
STD_TIME_COST_BY_USER = "std_time_costs_by_user"
|
|
STD_TIME_COST_BY_MODEL = "std_time_costs_by_model"
|
|
STD_TIME_COST_BY_MODULE = "std_time_costs_by_module" |