优化DifyExporter类,新增按日期范围过滤消息的功能,支持UTC+8时区的时间转换,并更新导出文件名以包含日期范围信息。同时,重构消息处理逻辑

This commit is contained in:
2025-07-09 16:50:35 +08:00
parent ffd0d52076
commit ec3db656a5
2 changed files with 104 additions and 45 deletions
+14 -6
View File
@@ -40,13 +40,18 @@ class PgSql:
如果连接失败,会抛出异常。
"""
try:
self.DIFY_PG_USER = os.getenv("DIFY_PG_USER")
self.DIFY_PG_PASSWORD = os.getenv("DIFY_PG_PASSWORD")
self.DIFY_PG_HOST = os.getenv("DIFY_PG_HOST")
self.DIFY_PG_PORT = os.getenv("DIFY_PG_PORT")
self.DIFY_PG_DATABASE = os.getenv("DIFY_PG_DATABASE")
# 连接数据库
self.connection = psycopg2.connect(
user=os.getenv("DIFY_PG_USER"),
password=os.getenv("DIFY_PG_PASSWORD"),
host=os.getenv("DIFY_PG_HOST"),
port=os.getenv("DIFY_PG_PORT"),
database=os.getenv("DIFY_PG_DATABASE")
user=self.DIFY_PG_USER,
password=self.DIFY_PG_PASSWORD,
host=self.DIFY_PG_HOST,
port=self.DIFY_PG_PORT,
database=self.DIFY_PG_DATABASE
)
except (Exception, psycopg2.Error) as error:
@@ -273,7 +278,10 @@ class DifyTool:
return None
workflow_node_executions_info = self.dify_pgsql.get_workflow_node_executions_info(messages_info['workflow_run_id'])
if not workflow_node_executions_info:
return None
return {
"messages_info": messages_info,
"workflow_node_executions_info": None
}
return {
"messages_info": messages_info,
"workflow_node_executions_info": workflow_node_executions_info