Simplify normalized AlbumPlayCountMode calc
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
. "github.com/Masterminds/squirrel"
|
||||
@@ -22,12 +21,10 @@ type albumRepository struct {
|
||||
|
||||
type dbAlbum struct {
|
||||
*model.Album `structs:",flatten"`
|
||||
Discs string `structs:"-" json:"discs"`
|
||||
PlayCount float64 `structs:"-" json:"play_count"`
|
||||
Discs string `structs:"-" json:"discs"`
|
||||
}
|
||||
|
||||
func (a *dbAlbum) PostScan() error {
|
||||
a.Album.PlayCount = int64(math.Round(a.PlayCount))
|
||||
if a.Discs != "" {
|
||||
return json.Unmarshal([]byte(a.Discs), &a.Album.Discs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user