Skip to content

Commit

Permalink
fix: card stats calculations in workflow executions (keephq#1835)
Browse files Browse the repository at this point in the history
Signed-off-by: Rajesh Jonnalagadda <[email protected]>
Co-authored-by: Tal <[email protected]>
  • Loading branch information
rajesh-jonnalagadda and talboren authored Sep 5, 2024
1 parent fd1eefa commit 8647fa8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions keep/api/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,17 +619,18 @@ def get_workflow_executions(tenant_id, workflow_id, limit=50, offset=0, tab=2, s


total_count = query.count()
status_counts = session.query(
status_counts = query.with_entities(
WorkflowExecution.status,
func.count().label('count')
).group_by(WorkflowExecution.status).all()

statusGroupbyMap = {status: count for status, count in status_counts}

passCount = statusGroupbyMap.get('success', 0)
failCount = statusGroupbyMap.get('error', 0) + statusGroupbyMap.get('timeout', 0)
passFail = (passCount / failCount) * 100 if failCount > 0 else 100.00

if passCount > 0:
passFail = (passCount / failCount) * 100 if failCount > 0 else 100.00
else:
passFail = 0.0
avgDuration = query.with_entities(func.avg(WorkflowExecution.execution_time)).scalar()
avgDuration = avgDuration if avgDuration else 0.0

Expand Down

0 comments on commit 8647fa8

Please sign in to comment.