File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
apps/sim/app/api/logs/stats Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -169,9 +169,16 @@ export async function GET(request: NextRequest) {
169169
170170 const existing = wf . segments . get ( segmentIndex )
171171 if ( existing ) {
172- existing . totalExecutions += Number ( row . totalExecutions )
172+ const oldTotal = existing . totalExecutions
173+ const newTotal = oldTotal + Number ( row . totalExecutions )
174+ existing . totalExecutions = newTotal
173175 existing . successfulExecutions += Number ( row . successfulExecutions )
174- existing . avgDurationMs = ( existing . avgDurationMs + Number ( row . avgDurationMs || 0 ) ) / 2
176+ existing . avgDurationMs =
177+ newTotal > 0
178+ ? ( existing . avgDurationMs * oldTotal +
179+ Number ( row . avgDurationMs || 0 ) * Number ( row . totalExecutions ) ) /
180+ newTotal
181+ : 0
175182 } else {
176183 wf . segments . set ( segmentIndex , {
177184 timestamp : new Date ( startTime . getTime ( ) + segmentIndex * segmentMs ) . toISOString ( ) ,
You can’t perform that action at this time.
0 commit comments