MCPcopy Create free account
hub / github.com/temporalio/temporal / BuildDigest

Function BuildDigest

tools/ci-notify/github.go:200–258  ·  view source on GitHub ↗

BuildDigest builds a digest report for the specified time range

(branch, workflowName string, days int)

Source from the content-addressed store, hash-verified

198
199// BuildDigest builds a digest report for the specified time range
200func BuildDigest(branch, workflowName string, days int) (*DigestReport, error) {
201 // Calculate the start date
202 endDate := time.Now()
203 startDate := endDate.AddDate(0, 0, -days)
204
205 // Fetch workflow runs
206 runs, err := GetWorkflowRuns(branch, workflowName, startDate)
207 if err != nil {
208 return nil, err
209 }
210
211 // Filter to only completed runs
212 completedRuns := filterCompleted(runs)
213
214 // Count successes and failures
215 var successCount, failureCount int
216 var durations []time.Duration
217
218 for _, run := range completedRuns {
219 switch run.Conclusion {
220 case ConclusionSuccess:
221 successCount++
222 default:
223 failureCount++
224 }
225
226 if run.Duration > 0 {
227 durations = append(durations, run.Duration)
228 }
229 }
230
231 totalRuns := len(completedRuns)
232 successRate := 0.0
233 if totalRuns > 0 {
234 successRate = (float64(successCount) / float64(totalRuns)) * 100
235 }
236
237 // Calculate duration percentiles
238 under20 := calculatePercentUnder(durations, 20*time.Minute)
239 under25 := calculatePercentUnder(durations, 25*time.Minute)
240 under30 := calculatePercentUnder(durations, 30*time.Minute)
241
242 return &DigestReport{
243 Branch: branch,
244 WorkflowName: workflowName,
245 StartDate: startDate,
246 EndDate: endDate,
247 TotalRuns: totalRuns,
248 SuccessfulRuns: successCount,
249 FailedRuns: failureCount,
250 SuccessRate: successRate,
251 AverageDuration: calculateAverage(durations),
252 MedianDuration: calculateMedian(durations),
253 Under20MinutesPercent: under20,
254 Under25MinutesPercent: under25,
255 Under30MinutesPercent: under30,
256 Runs: completedRuns,
257 }, nil

Callers 1

runDigestCommandFunction · 0.85

Calls 6

GetWorkflowRunsFunction · 0.85
filterCompletedFunction · 0.85
calculatePercentUnderFunction · 0.85
calculateAverageFunction · 0.85
calculateMedianFunction · 0.85
NowMethod · 0.65

Tested by

no test coverage detected