From a66b5554ce734af58da9281d59478b5d9b8e6413 Mon Sep 17 00:00:00 2001 From: Thom Shutt Date: Wed, 9 Nov 2022 20:15:46 +0000 Subject: [PATCH 1/2] Transcode completion % should reflect that there's now a DTSH generation stage after transcoding --- clients/callback_client.go | 6 ++++-- clients/callback_client_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clients/callback_client.go b/clients/callback_client.go index a6219c901..a5495d7cc 100644 --- a/clients/callback_client.go +++ b/clients/callback_client.go @@ -156,8 +156,10 @@ func overallCompletionRatio(status TranscodeStatus, currentStageCompletionRatio switch status { case TranscodeStatusPreparing, TranscodeStatusPreparingCompleted: return scaleProgress(currentStageCompletionRatio, 0, 0.4) - case TranscodeStatusTranscoding, TranscodeStatusCompleted: - return scaleProgress(currentStageCompletionRatio, 0.4, 1) + case TranscodeStatusTranscoding: + return scaleProgress(currentStageCompletionRatio, 0.4, 0.9) + case TranscodeStatusCompleted: + return scaleProgress(currentStageCompletionRatio, 0.9, 1) } // Either unhandled or an error diff --git a/clients/callback_client_test.go b/clients/callback_client_test.go index 15e104bfd..a8deb7809 100644 --- a/clients/callback_client_test.go +++ b/clients/callback_client_test.go @@ -101,7 +101,7 @@ func TestItCalculatesTheOverallCompletionRatioCorrectly(t *testing.T) { }{ {TranscodeStatusPreparing, 0.5, 0.2}, // Half complete in the Preparing stage (i.e half way between 0 and 0.4) {TranscodeStatusPreparingCompleted, 1234, 0.4}, // Preparing Completed should always == 0.4 for now, regardless of what's reported as the stage ratio - {TranscodeStatusTranscoding, 0.5, 0.7}, // Half complete in the Transcoding stage (i.e half way between 0.4 and 1) + {TranscodeStatusTranscoding, 0.5, 0.65}, // Half complete in the Transcoding stage (i.e half way between 0.4 and 0.9) {TranscodeStatusCompleted, 5678, 1}, // Completed should always == 1, regardless of what's reported as the stage ratio } for _, tc := range testCases { From 6cfba7db7a59a9c9b59a6bdd603f5e7ff3525d89 Mon Sep 17 00:00:00 2001 From: Thom Shutt Date: Wed, 9 Nov 2022 22:30:27 +0000 Subject: [PATCH 2/2] Fix failing test --- transcode/transcode_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transcode/transcode_test.go b/transcode/transcode_test.go index 45ff39183..82c72289d 100644 --- a/transcode/transcode_test.go +++ b/transcode/transcode_test.go @@ -136,8 +136,8 @@ func TestItCanTranscode(t *testing.T) { // Check we received a progress callback for each segment require.Equal(t, 3, len(callbacks)) - require.Equal(t, 0.7, callbacks[0]["completion_ratio"]) - require.Equal(t, 1.0, callbacks[1]["completion_ratio"]) + require.Equal(t, 0.65, callbacks[0]["completion_ratio"]) + require.Equal(t, 0.9, callbacks[1]["completion_ratio"]) // Check we received a final Transcode Completed callback require.Equal(t, 1.0, callbacks[2]["completion_ratio"])