🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Removed unused code
Deluanc73f64ee3a28
diff --git a/core/playlists_test.go b/core/playlists_test.goindex ab5d76831..8aafabb7f 100644--- a/core/playlists_test.go+++ b/core/playlists_test.go@@ -6,7 +6,6 @@ import ("github.com/navidrome/navidrome/model""github.com/navidrome/navidrome/tests"-. "github.com/onsi/ginkgo". "github.com/onsi/gomega")diff --git a/model/criteria/criteria.go b/model/criteria/criteria.goindex 32f355951..394c5590a 100644--- a/model/criteria/criteria.go+++ b/model/criteria/criteria.go@@ -35,9 +35,9 @@ func (c Criteria) MarshalJSON() ([]byte, error) {aux := struct {All []Expression `json:"all,omitempty"`Any []Expression `json:"any,omitempty"`- Sort string `json:"sort"`+ Sort string `json:"sort,omitempty"`Order string `json:"order,omitempty"`- Limit int `json:"limit"`+ Limit int `json:"limit,omitempty"`Offset int `json:"offset,omitempty"`}{Sort: c.Sort,diff --git a/model/smartplaylist.go b/model/smartplaylist.godeleted file mode 100644index 70b6d1ca7..000000000--- a/model/smartplaylist.go+++ /dev/null@@ -1,106 +0,0 @@-package model--import (- "encoding/json"- "errors"-)--type SmartPlaylist struct {- RuleGroup- Order string `json:"order,omitempty"`- Limit int `json:"limit,omitempty"`-}--type RuleGroup struct {- Combinator string `json:"combinator"`- Rules Rules `json:"rules"`-}--type Rules []IRule--type IRule interface {- Fields() []string-}--type Rule struct {- Field string `json:"field"`- Operator string `json:"operator"`- Value interface{} `json:"value,omitempty"`-}--func (r Rule) Fields() []string {- return []string{r.Field}-}--func (rg RuleGroup) Fields() []string {- var result []string- unique := map[string]struct{}{}- for _, r := range rg.Rules {- for _, f := range r.Fields() {- if _, added := unique[f]; !added {- result = append(result, f)- unique[f] = struct{}{}- }- }- }- return result-}--func (rs *Rules) UnmarshalJSON(data []byte) error {- var rawRules []json.RawMessage- if err := json.Unmarshal(data, &rawRules); err != nil {- return err- }- rules := make(Rules, len(rawRules))- for i, rawRule := range rawRules {- var r Rule- if err := json.Unmarshal(rawRule, &r); err == nil && r.Field != "" {- rules[i] = r- continue- }- var g RuleGroup- if err := json.Unmarshal(rawRule, &g); err == nil && g.Combinator != "" {- rules[i] = g- continue- }- return errors.New("Invalid json. Neither a Rule nor a RuleGroup: " + string(rawRule))- }- *rs = rules- return nil-}--var SmartPlaylistFields = []string{- "title",- "album",- "artist",- "albumartist",- "albumartwork",- "tracknumber",- "discnumber",- "year",- "size",- "compilation",- "dateadded",- "datemodified",- "discsubtitle",- "comment",- "lyrics",- "sorttitle",- "sortalbum",- "sortartist",- "sortalbumartist",- "albumtype",- "albumcomment",- "catalognumber",- "filepath",- "filetype",- "duration",- "bitrate",- "bpm",- "channels",- "genre",- "loved",- "lastplayed",- "playcount",- "rating",-}diff --git a/model/smartplaylist_test.go b/model/smartplaylist_test.godeleted file mode 100644index 2f2e73530..000000000--- a/model/smartplaylist_test.go+++ /dev/null@@ -1,101 +0,0 @@-package model_test--import (- "bytes"- "encoding/json"-- "github.com/navidrome/navidrome/model"- . "github.com/onsi/ginkgo"- . "github.com/onsi/gomega"-)--var _ = Describe("SmartPlaylist", func() {- var goObj model.SmartPlaylist- var jsonObj string- BeforeEach(func() {- goObj = model.SmartPlaylist{- RuleGroup: model.RuleGroup{- Combinator: "and", Rules: model.Rules{- model.Rule{Field: "title", Operator: "contains", Value: "love"},- model.Rule{Field: "year", Operator: "is in the range", Value: []int{1980, 1989}},- model.Rule{Field: "loved", Operator: "is true"},- model.Rule{Field: "lastPlayed", Operator: "in the last", Value: 30},- model.RuleGroup{- Combinator: "or",- Rules: model.Rules{- model.Rule{Field: "artist", Operator: "is not", Value: "zé"},- model.Rule{Field: "album", Operator: "is", Value: "4"},- },- },- }},- Order: "artist asc",- Limit: 100,- }- var b bytes.Buffer- err := json.Compact(&b, []byte(`-{- "combinator":"and",- "rules":[- {- "field":"title",- "operator":"contains",- "value":"love"- },- {- "field":"year",- "operator":"is in the range",- "value":[- 1980,- 1989- ]- },- {- "field":"loved",- "operator":"is true"- },- {- "field":"lastPlayed",- "operator":"in the last",- "value":30- },- {- "combinator":"or",- "rules":[- {- "field":"artist",- "operator":"is not",- "value":"zé"- },- {- "field":"album",- "operator":"is",- "value":"4"- }- ]- }- ],- "order":"artist asc",- "limit":100-}`))- if err != nil {- panic(err)- }- jsonObj = b.String()- })- It("finds all fields", func() {- Expect(goObj.Fields()).To(ConsistOf("title", "year", "loved", "lastPlayed", "artist", "album"))- })- It("marshals to JSON", func() {- j, err := json.Marshal(goObj)- Expect(err).ToNot(HaveOccurred())- Expect(string(j)).To(Equal(jsonObj))- })- It("is reversible to/from JSON", func() {- var newObj model.SmartPlaylist- err := json.Unmarshal([]byte(jsonObj), &newObj)- Expect(err).ToNot(HaveOccurred())- j, err := json.Marshal(newObj)- Expect(err).ToNot(HaveOccurred())- Expect(string(j)).To(Equal(jsonObj))- })-})