mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-25 19:39:46 +01:00
Refactored NowPlaying
Also added a test case for skipping range
This commit is contained in:
parent
3c8f6e9a65
commit
1cf8a0db44
5 changed files with 51 additions and 20 deletions
|
|
@ -3,7 +3,6 @@ package persistence
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/deluan/gosonic/engine"
|
||||
)
|
||||
|
|
@ -26,15 +25,13 @@ func nowPlayingKeyName(playerId int) string {
|
|||
return fmt.Sprintf("%s:%d", nowPlayingKeyPrefix, playerId)
|
||||
}
|
||||
|
||||
func (r *nowPlayingRepository) Enqueue(playerId int, playerName, id, username string) error {
|
||||
m := &engine.NowPlayingInfo{TrackId: id, Username: username, Start: time.Now(), PlayerId: playerId, PlayerName: playerName}
|
||||
|
||||
h, err := json.Marshal(m)
|
||||
func (r *nowPlayingRepository) Enqueue(info *engine.NowPlayingInfo) error {
|
||||
h, err := json.Marshal(info)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
keyName := []byte(nowPlayingKeyName(playerId))
|
||||
keyName := []byte(nowPlayingKeyName(info.PlayerId))
|
||||
|
||||
_, err = Db().LPush(keyName, []byte(h))
|
||||
Db().LExpire(keyName, int64(engine.NowPlayingExpire.Seconds()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue