From ea99b6c119fd59c18a26dadac2d3b2eac1f419d1 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Mon, 6 Jul 2026 12:16:15 +0700 Subject: [PATCH] fix(misc): tune wheel beta timing --- internal/modules/misc/handlers_test.go | 14 ++++++++++++-- internal/modules/misc/wheelofnames_beta.go | 14 ++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/internal/modules/misc/handlers_test.go b/internal/modules/misc/handlers_test.go index da0f23a..0b53928 100644 --- a/internal/modules/misc/handlers_test.go +++ b/internal/modules/misc/handlers_test.go @@ -254,15 +254,25 @@ func TestWheelOfNamesBeta_RenderGIFTiming(t *testing.T) { t.Fatalf("frames = %d, want %d", len(decoded.Image), wheelBetaSpinFrames+1) } totalDelay := 0 + spinDelay := 0 for i, delay := range decoded.Delay { totalDelay += delay if i < wheelBetaSpinFrames && delay != wheelBetaSpinDelay { t.Fatalf("spin delay[%d] = %d, want %d", i, delay, wheelBetaSpinDelay) } + if i < wheelBetaSpinFrames { + spinDelay += delay + } + } + if spinDelay != wheelBetaSpinDuration*100 { + t.Fatalf("spin delay total = %dcs, want %dcs", spinDelay, wheelBetaSpinDuration*100) } if got := decoded.Delay[len(decoded.Delay)-1]; got != wheelBetaHoldDelay { t.Fatalf("hold delay = %d, want %d", got, wheelBetaHoldDelay) } + if got := decoded.Delay[len(decoded.Delay)-1]; got != wheelBetaHoldDuration*100 { + t.Fatalf("hold delay total = %dcs, want %dcs", got, wheelBetaHoldDuration*100) + } if totalDelay != wheelBetaDuration*100 { t.Fatalf("total delay = %dcs, want %dcs", totalDelay, wheelBetaDuration*100) } @@ -294,8 +304,8 @@ func TestWheelOfNamesBeta_SendsAnimationWithoutSpoilingCaption(t *testing.T) { if strings.Contains(call.Form["caption"], "Alice") { t.Fatalf("caption spoils winner: %q", call.Form["caption"]) } - if got := call.Form["duration"]; got != "7" { - t.Fatalf("duration = %q, want 7", got) + if got := call.Form["duration"]; got != "10" { + t.Fatalf("duration = %q, want 10", got) } if got := call.Form["width"]; got != "320" { t.Fatalf("width = %q, want 320", got) diff --git a/internal/modules/misc/wheelofnames_beta.go b/internal/modules/misc/wheelofnames_beta.go index dd55e75..ee89cab 100644 --- a/internal/modules/misc/wheelofnames_beta.go +++ b/internal/modules/misc/wheelofnames_beta.go @@ -16,12 +16,14 @@ import ( ) const ( - wheelBetaSize = 320 - wheelBetaRadius = 118 - wheelBetaSpinFrames = 30 - wheelBetaSpinDelay = 20 - wheelBetaHoldDelay = 100 - wheelBetaDuration = 7 + wheelBetaSize = 320 + wheelBetaRadius = 118 + wheelBetaSpinDuration = 7 + wheelBetaHoldDuration = 3 + wheelBetaSpinDelay = 20 + wheelBetaSpinFrames = wheelBetaSpinDuration * 100 / wheelBetaSpinDelay + wheelBetaHoldDelay = wheelBetaHoldDuration * 100 + wheelBetaDuration = wheelBetaSpinDuration + wheelBetaHoldDuration ) var wheelBetaPalette = color.Palette{