106
107
if err := workflow.SetQueryHandler(ctx, StatsQuery, func() (DeleteExecutionsStats, error) {
109
>
des := DeleteExecutionsStats{
110
>
DeleteExecutionsResult: result,
111
>
ContinueAsNewCount: params.ContinueAsNewCount,
112
>
TotalExecutionsCount: params.TotalExecutionsCount,
113
>
StartTime: params.FirstRunStartTime,
114
>
}
115
>
if params.TotalExecutionsCount > 0 {
116
>
des.RemainingExecutionsCount = params.TotalExecutionsCount - (result.SuccessCount + result.ErrorCount)
117
>
}
118
>
secondsSinceStart := int(now.Sub(params.FirstRunStartTime).Seconds())
119
>
if secondsSinceStart > 0 {
120
>
des.AverageRPS = (result.SuccessCount + result.ErrorCount) / secondsSinceStart
121
>
}
122
>
if des.AverageRPS > 0 {
123
>
des.ApproximateTimeLeft = time.Duration(des.RemainingExecutionsCount/des.AverageRPS) * time.Second
124
>
}
125
>
des.ApproximateEndTime = now.Add(des.ApproximateTimeLeft)
126
>
return des, nil
127
}); err != nil {
128
return result, err