From 33efce52f9f0ca573f2ddf6bb6e2cfe3e7c6aa82 Mon Sep 17 00:00:00 2001 From: ANDREY KHASANOV Date: Fri, 22 Dec 2023 09:47:29 +0200 Subject: [PATCH] Refactor delay limit setting in request_limits.go The delay limit setting logic in 'request_limits.go' has been reorganized for increased efficiency. The changes ensure the correct delay value is consistently set in the structure. Additionally, newline characters have been included for better file readability. --- internal/repo/model/request_limits.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/repo/model/request_limits.go b/internal/repo/model/request_limits.go index d46c349..f337cc9 100644 --- a/internal/repo/model/request_limits.go +++ b/internal/repo/model/request_limits.go @@ -212,14 +212,15 @@ func (r *RequestLimitsV2) CleanCounters() []RequestsV2 { tt := batch.Start.Add(time.Duration(key+uint32(counter)) * time.Second) if time.Since(tt) < window { - value := int32(tt.Sub(newStart).Seconds()) + value := uint32(tt.Sub(newStart).Seconds()) if j != len(batch.Data)-1 { data = batch.Data[j:] + data[0] = value + } else { + data = []uint32{value} } - data[0] = uint32(value) - reached = true break