From 38f7d76246f2f97c29f6b26ca91727127f1f801f Mon Sep 17 00:00:00 2001 From: Dustin Moris Gorski Date: Tue, 9 Nov 2021 20:44:48 +0000 Subject: [PATCH 1/2] Should fix #44 --- src/BuildStats/BuildHistoryCharts.fs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/BuildStats/BuildHistoryCharts.fs b/src/BuildStats/BuildHistoryCharts.fs index 5482d3d..d1f1a56 100644 --- a/src/BuildStats/BuildHistoryCharts.fs +++ b/src/BuildStats/BuildHistoryCharts.fs @@ -25,6 +25,12 @@ module BuildChartTypes = FromPullRequest : bool } + member this.HasCompleted() = + match this.Status with + | Success + | Failed -> true + | _ -> false + // ------------------------------------------- // Helper Functions // ------------------------------------------- @@ -38,7 +44,7 @@ module BuildStatsHelper = inclFromPullRequest || not build.FromPullRequest let timeTaken (started : Nullable) - (finished : Nullable) = + (finished : Nullable) = match started.HasValue with | true -> match finished.HasValue with @@ -59,6 +65,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds + |> List.filter (fun b -> b.HasCompleted()) |> List.maxBy (fun x -> x.TimeTaken.TotalMilliseconds) |> fun x -> x.TimeTaken @@ -67,6 +74,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds + |> List.filter (fun b -> b.HasCompleted()) |> List.minBy (fun x -> x.TimeTaken.TotalMilliseconds) |> fun x -> x.TimeTaken @@ -75,6 +83,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds + |> List.filter (fun b -> b.HasCompleted()) |> List.averageBy (fun x -> x.TimeTaken.TotalMilliseconds) |> TimeSpan.FromMilliseconds From 40fc2dfb48bd2bb4ff446fb8b16270e64898c36b Mon Sep 17 00:00:00 2001 From: Dustin Moris Gorski Date: Tue, 9 Nov 2021 21:15:07 +0000 Subject: [PATCH 2/2] Only count successful builds because failed ones don't really matter --- src/BuildStats/BuildHistoryCharts.fs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/BuildStats/BuildHistoryCharts.fs b/src/BuildStats/BuildHistoryCharts.fs index d1f1a56..14337ab 100644 --- a/src/BuildStats/BuildHistoryCharts.fs +++ b/src/BuildStats/BuildHistoryCharts.fs @@ -25,12 +25,6 @@ module BuildChartTypes = FromPullRequest : bool } - member this.HasCompleted() = - match this.Status with - | Success - | Failed -> true - | _ -> false - // ------------------------------------------- // Helper Functions // ------------------------------------------- @@ -65,7 +59,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds - |> List.filter (fun b -> b.HasCompleted()) + |> List.filter (fun b -> b.Status = Success) |> List.maxBy (fun x -> x.TimeTaken.TotalMilliseconds) |> fun x -> x.TimeTaken @@ -74,7 +68,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds - |> List.filter (fun b -> b.HasCompleted()) + |> List.filter (fun b -> b.Status = Success) |> List.minBy (fun x -> x.TimeTaken.TotalMilliseconds) |> fun x -> x.TimeTaken @@ -83,7 +77,7 @@ module BuildMetrics = | 0 -> TimeSpan.Zero | _ -> builds - |> List.filter (fun b -> b.HasCompleted()) + |> List.filter (fun b -> b.Status = Success) |> List.averageBy (fun x -> x.TimeTaken.TotalMilliseconds) |> TimeSpan.FromMilliseconds