From a8a9a991d41c5ac693c0b40fa655f837e7035241 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 5 Jan 2025 18:34:15 +0400 Subject: [PATCH] Fixed var naming in ListenerCounter. --- internal/radio/listener_counter.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/radio/listener_counter.go b/internal/radio/listener_counter.go index e30e620..2a69349 100644 --- a/internal/radio/listener_counter.go +++ b/internal/radio/listener_counter.go @@ -10,8 +10,8 @@ import ( // ListenerCounter stores the current, overall and peak numbers of listeners. type ListenerCounter struct { sync.RWMutex - current, peak int64 - overall, cur_peak int64 + current, currentPeak int64 + overall, peak int64 } // NewListenerCounter returns a new ListenerCounter struct instance. @@ -31,7 +31,7 @@ func (l *ListenerCounter) Peak() int64 { // CurrentPeak returns a peak number of listeners for a currently playing song. func (l *ListenerCounter) CurrentPeak() int64 { - return l.cur_peak + return l.currentPeak } // Overall returns an overall number of listeners for a currently playing song. @@ -46,12 +46,12 @@ func (l *ListenerCounter) Inc() int64 { panic("a current number of listeners exceeded MaxInt64") } l.current++ + if l.current > l.currentPeak { + l.currentPeak = l.current + } if l.current > l.peak { l.peak = l.current } - if l.current > l.cur_peak { - l.cur_peak = l.current - } if l.overall == math.MaxInt64 { panic("an overall number of listeners exceeded MaxInt64") } @@ -72,9 +72,9 @@ func (l *ListenerCounter) Dec() (int64, error) { // Reset current peak and overall listeners for a song that is playing. // And return its values. func (l *ListenerCounter) Reset() (overall, peak int64) { - peak = l.cur_peak - l.cur_peak = l.current + peak = l.peak overall = l.overall + l.peak = l.current l.overall = l.current return } @@ -82,12 +82,12 @@ func (l *ListenerCounter) Reset() (overall, peak int64) { func (l *ListenerCounter) MarshalJSON() ([]byte, error) { return json.Marshal(&struct { Current int64 `json:"current"` + CurPeak int64 `json:"current_peak"` Peak int64 `json:"peak"` Overall int64 `json:"overall"` - CurPeak int64 `json:"current_peak"` }{ Current: l.current, + CurPeak: l.currentPeak, Peak: l.peak, - Overall: l.overall, - CurPeak: l.cur_peak}) + Overall: l.overall}) }