A MaxListeners field of a Song struct was renamed to a more logically appropriate PeakListeners.
This commit is contained in:
parent
4feeb518fc
commit
872e8f4978
@ -112,7 +112,7 @@ func main() {
|
|||||||
switch <-sysSignal {
|
switch <-sysSignal {
|
||||||
case os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV:
|
case os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV:
|
||||||
if currentSong.Artist != "" {
|
if currentSong.Artist != "" {
|
||||||
currentSong.Listeners, currentSong.MaxListeners = lstnrs.Reset()
|
currentSong.Listeners, currentSong.PeakListeners = lstnrs.Reset()
|
||||||
if err := stats.Add(¤tSong); err != nil {
|
if err := stats.Add(¤tSong); err != nil {
|
||||||
log.Println("failed to save a current song during a shutdown:", err)
|
log.Println("failed to save a current song during a shutdown:", err)
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) {
|
|||||||
newSong.Artist = "Nothing to play. Playing a fallback: " + newSong.Artist
|
newSong.Artist = "Nothing to play. Playing a fallback: " + newSong.Artist
|
||||||
}
|
}
|
||||||
|
|
||||||
dj.curSong.Listeners, dj.curSong.MaxListeners = dj.listeners.Reset()
|
dj.curSong.Listeners, dj.curSong.PeakListeners = dj.listeners.Reset()
|
||||||
|
|
||||||
if dj.curSong.Artist != "" {
|
if dj.curSong.Artist != "" {
|
||||||
if err := dj.stats.Add(dj.curSong); err != nil {
|
if err := dj.stats.Add(dj.curSong); err != nil {
|
||||||
@ -118,7 +118,7 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) {
|
|||||||
|
|
||||||
*dj.curSong = newSong
|
*dj.curSong = newSong
|
||||||
dj.curSong.Listeners = 0
|
dj.curSong.Listeners = 0
|
||||||
dj.curSong.MaxListeners = 0
|
dj.curSong.PeakListeners = 0
|
||||||
// }()
|
// }()
|
||||||
|
|
||||||
fmt.Fprintln(w, nxt)
|
fmt.Fprintln(w, nxt)
|
||||||
|
@ -6,12 +6,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Song struct {
|
type Song struct {
|
||||||
Artist string
|
Artist string
|
||||||
Title string
|
Title string
|
||||||
StartAt time.Time
|
StartAt time.Time
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
Listeners int64
|
Listeners int64
|
||||||
MaxListeners int64
|
PeakListeners int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// DurationString returns song's duration as a string formatted as [H:]M:SS.
|
// DurationString returns song's duration as a string formatted as [H:]M:SS.
|
||||||
@ -24,17 +24,17 @@ func (s *Song) DurationString() string {
|
|||||||
|
|
||||||
func (s *Song) MarshalJSON() ([]byte, error) {
|
func (s *Song) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(&struct {
|
return json.Marshal(&struct {
|
||||||
Artist string `json:"artist"`
|
Artist string `json:"artist"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
DurationMill int64 `json:"duration_msec,omitempty"`
|
DurationMill int64 `json:"duration_msec,omitempty"`
|
||||||
Listeners int64 `json:"listeners"`
|
Listeners int64 `json:"listeners"`
|
||||||
MaxListeners int64 `json:"max_listeners"`
|
PeakListeners int64 `json:"max_listeners"`
|
||||||
StartAt string `json:"start_at"`
|
StartAt string `json:"start_at"`
|
||||||
}{
|
}{
|
||||||
Artist: s.Artist,
|
Artist: s.Artist,
|
||||||
Title: s.Title,
|
Title: s.Title,
|
||||||
DurationMill: s.Duration.Milliseconds(),
|
DurationMill: s.Duration.Milliseconds(),
|
||||||
Listeners: s.Listeners,
|
Listeners: s.Listeners,
|
||||||
MaxListeners: s.MaxListeners,
|
PeakListeners: s.PeakListeners,
|
||||||
StartAt: s.StartAt.UTC().Format(time.RFC3339)})
|
StartAt: s.StartAt.UTC().Format(time.RFC3339)})
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ func (s *SQLiteStatistics) Add(song *radio.Song) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res, err := tx.Stmt(stmtHistoryAdd).Exec(song.StartAt.UTC().Format(dbDateFormat),
|
res, err := tx.Stmt(stmtHistoryAdd).Exec(song.StartAt.UTC().Format(dbDateFormat),
|
||||||
songID, song.Listeners, song.MaxListeners)
|
songID, song.Listeners, song.PeakListeners)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if ra, err := res.RowsAffected(); ra == 0 || err != nil {
|
} else if ra, err := res.RowsAffected(); ra == 0 || err != nil {
|
||||||
@ -150,7 +150,7 @@ func (s *SQLiteStatistics) LastNSongs(n int64) ([]radio.Song, error) {
|
|||||||
var startAt string
|
var startAt string
|
||||||
|
|
||||||
if err := rows.Scan(&startAt, &songs[i].Artist, &songs[i].Title,
|
if err := rows.Scan(&startAt, &songs[i].Artist, &songs[i].Title,
|
||||||
&songs[i].Listeners, &songs[i].MaxListeners); err != nil {
|
&songs[i].Listeners, &songs[i].PeakListeners); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ if sl != nil && len(sl) != 0 {
|
|||||||
<thead class="small">
|
<thead class="small">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Start</td>
|
<td>Start</td>
|
||||||
<td><abbr title="Overall/Max listeners">O/M</abbr></td>
|
<td><abbr title="Overall/Peak listeners">O/P</abbr></td>
|
||||||
<td>Song</td>
|
<td>Song</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -91,8 +91,8 @@ if sl != nil && len(sl) != 0 {
|
|||||||
for i := 0; i < len(sl); i++ {
|
for i := 0; i < len(sl); i++ {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{ utils.ToClientTimezone(sl[i].StartAt, r).Format("15:04") }</td>
|
<td>{ utils.ToClientTimezone(sl[i].StartAt, r).Format("15:04") }</td>
|
||||||
if sl[i].MaxListeners != 0 {
|
if sl[i].PeakListeners != 0 {
|
||||||
<td>{ strconv.FormatInt(sl[i].Listeners, 10) }/{ strconv.FormatInt(sl[i].MaxListeners, 10) }</td>
|
<td>{ strconv.FormatInt(sl[i].Listeners, 10) }/{ strconv.FormatInt(sl[i].PeakListeners, 10) }</td>
|
||||||
} else {
|
} else {
|
||||||
<td></td>
|
<td></td>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user