mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Fix dateLoved
in criteria. Now log invalid field names in criteria
This commit is contained in:
parent
a4d3bf42a7
commit
8c2e4da396
2 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,8 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/log"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
)
|
||||
|
||||
|
@ -21,6 +23,10 @@ type Criteria struct {
|
|||
|
||||
func (c Criteria) OrderBy() string {
|
||||
f := fieldMap[strings.ToLower(c.Sort)]
|
||||
if f == "" {
|
||||
log.Error("Invalid field in 'sort' field", "field", c.Sort)
|
||||
f = c.Sort
|
||||
}
|
||||
if c.Order != "" {
|
||||
f = f + " " + c.Order
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/log"
|
||||
)
|
||||
|
||||
var fieldMap = map[string]string{
|
||||
|
@ -37,7 +39,7 @@ var fieldMap = map[string]string{
|
|||
"channels": "media_file.channels",
|
||||
"genre": "genre.name",
|
||||
"loved": "annotation.starred",
|
||||
"dateLoved": "annotation.starred_at",
|
||||
"dateloved": "annotation.starred_at",
|
||||
"lastplayed": "annotation.play_date",
|
||||
"playcount": "annotation.play_count",
|
||||
"rating": "annotation.rating",
|
||||
|
@ -48,6 +50,8 @@ func mapFields(expr map[string]interface{}) map[string]interface{} {
|
|||
for f, v := range expr {
|
||||
if dbf, found := fieldMap[strings.ToLower(f)]; found {
|
||||
m[dbf] = v
|
||||
} else {
|
||||
log.Error("Invalid field in criteria", "field", f)
|
||||
}
|
||||
}
|
||||
return m
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue