chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,90 @@
|
||||
"""Application service for workflow statistic queries."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from machinery.context import RequestContext
|
||||
from models.enums import WorkflowRunTriggeredFrom
|
||||
from repositories.api_workflow_run_repository import APIWorkflowRunRepository
|
||||
from repositories.types import (
|
||||
AverageInteractionStats,
|
||||
DailyRunsStats,
|
||||
DailyTerminalsStats,
|
||||
DailyTokenCostStats,
|
||||
)
|
||||
|
||||
|
||||
class WorkflowStatisticQueryService:
|
||||
def __init__(self, *, workflow_runs: APIWorkflowRunRepository) -> None:
|
||||
self._workflow_runs = workflow_runs
|
||||
|
||||
def get_daily_runs(
|
||||
self,
|
||||
context: RequestContext,
|
||||
*,
|
||||
app_id: str,
|
||||
start_date: datetime | None,
|
||||
end_date: datetime | None,
|
||||
timezone: str,
|
||||
) -> list[DailyRunsStats]:
|
||||
return self._workflow_runs.get_daily_runs_statistics(
|
||||
tenant_id=context.active_workspace_id,
|
||||
app_id=app_id,
|
||||
triggered_from=WorkflowRunTriggeredFrom.APP_RUN,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
timezone=timezone,
|
||||
)
|
||||
|
||||
def get_daily_terminals(
|
||||
self,
|
||||
context: RequestContext,
|
||||
*,
|
||||
app_id: str,
|
||||
start_date: datetime | None,
|
||||
end_date: datetime | None,
|
||||
timezone: str,
|
||||
) -> list[DailyTerminalsStats]:
|
||||
return self._workflow_runs.get_daily_terminals_statistics(
|
||||
tenant_id=context.active_workspace_id,
|
||||
app_id=app_id,
|
||||
triggered_from=WorkflowRunTriggeredFrom.APP_RUN,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
timezone=timezone,
|
||||
)
|
||||
|
||||
def get_daily_token_costs(
|
||||
self,
|
||||
context: RequestContext,
|
||||
*,
|
||||
app_id: str,
|
||||
start_date: datetime | None,
|
||||
end_date: datetime | None,
|
||||
timezone: str,
|
||||
) -> list[DailyTokenCostStats]:
|
||||
return self._workflow_runs.get_daily_token_cost_statistics(
|
||||
tenant_id=context.active_workspace_id,
|
||||
app_id=app_id,
|
||||
triggered_from=WorkflowRunTriggeredFrom.APP_RUN,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
timezone=timezone,
|
||||
)
|
||||
|
||||
def get_average_app_interactions(
|
||||
self,
|
||||
context: RequestContext,
|
||||
*,
|
||||
app_id: str,
|
||||
start_date: datetime | None,
|
||||
end_date: datetime | None,
|
||||
timezone: str,
|
||||
) -> list[AverageInteractionStats]:
|
||||
return self._workflow_runs.get_average_app_interaction_statistics(
|
||||
tenant_id=context.active_workspace_id,
|
||||
app_id=app_id,
|
||||
triggered_from=WorkflowRunTriggeredFrom.APP_RUN,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
timezone=timezone,
|
||||
)
|
||||
Reference in new issue
Block a user