mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-05 21:01:08 +03:00
go tidy
This commit is contained in:
parent
5a41fb13b8
commit
6bbb0dae15
@ -184,24 +184,24 @@ func handleAlbum(matchResults map[string]string, ret []interface{}, cds *content
|
||||
func handleGenre(matchResults map[string]string, ret []interface{}, cds *contentDirectoryService, o contentDirectoryObject, host string) ([]interface{}, error) {
|
||||
if matchResults["GenreArtist"] != "" {
|
||||
/*
|
||||
SELECT * FROM media_file WHERE
|
||||
EXISTS (
|
||||
SELECT 1 FROM json_each(tags, '$.genre')
|
||||
WHERE json_extract(value, '$.id') == '7bLYq0Np81m1Wgy5N31nuG'
|
||||
SELECT * FROM media_file WHERE
|
||||
EXISTS (
|
||||
SELECT 1 FROM json_each(tags, '$.genre')
|
||||
WHERE json_extract(value, '$.id') == '7bLYq0Np81m1Wgy5N31nuG'
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM json_each(participants, '$.artist')
|
||||
WHERE json_extract(value, '$.id') == '4CBFO1ymQXgsbXQgV2aPMI'
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM json_each(participants, '$.artist')
|
||||
WHERE json_extract(value, '$.id') == '4CBFO1ymQXgsbXQgV2aPMI'
|
||||
)
|
||||
LIMIT 100
|
||||
LIMIT 100
|
||||
*/
|
||||
|
||||
thisFilter := squirrel.And{
|
||||
persistence.Exists("json_tree(tags, '$.genre')", squirrel.And{
|
||||
persistence.Exists("json_tree(tags, '$.genre')", squirrel.And{
|
||||
squirrel.Eq{"key": "id"},
|
||||
squirrel.Eq{"value": matchResults["Genre"]},
|
||||
}),
|
||||
persistence.Exists("json_tree(participants, '$.artist')", squirrel.And{
|
||||
persistence.Exists("json_tree(participants, '$.artist')", squirrel.And{
|
||||
squirrel.Eq{"key": "id"},
|
||||
squirrel.Eq{"value": matchResults["GenreArtist"]},
|
||||
}),
|
||||
@ -216,26 +216,26 @@ func handleGenre(matchResults map[string]string, ret []interface{}, cds *content
|
||||
} else if matchResults["Genre"] != "" {
|
||||
if matchResults["GenreArtist"] == "" {
|
||||
/*
|
||||
// slightly cleaner query:
|
||||
// slightly cleaner query:
|
||||
|
||||
SELECT
|
||||
json_extract(a.value, '$.name') artist_name,
|
||||
json_extract(a.value, '$.id') artist_id,
|
||||
COUNT(*)
|
||||
FROM
|
||||
media_file f,
|
||||
json_each(f.tags, '$.genre') as g,
|
||||
json_each(f.participants, '$.artist') as a
|
||||
WHERE
|
||||
json_extract(g.value, '$.id') = '7bLYq0Np81m1Wgy5N31nuG'
|
||||
GROUP BY artist_id;
|
||||
SELECT
|
||||
json_extract(a.value, '$.name') artist_name,
|
||||
json_extract(a.value, '$.id') artist_id,
|
||||
COUNT(*)
|
||||
FROM
|
||||
media_file f,
|
||||
json_each(f.tags, '$.genre') as g,
|
||||
json_each(f.participants, '$.artist') as a
|
||||
WHERE
|
||||
json_extract(g.value, '$.id') = '7bLYq0Np81m1Wgy5N31nuG'
|
||||
GROUP BY artist_id;
|
||||
*/
|
||||
|
||||
thisFilter := persistence.Exists("json_tree(tags, '$.genre')", squirrel.And{
|
||||
thisFilter := persistence.Exists("json_tree(tags, '$.genre')", squirrel.And{
|
||||
squirrel.Eq{"key": "id"},
|
||||
squirrel.Eq{"value": matchResults["Genre"]},
|
||||
})
|
||||
mediaFiles, err := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: thisFilter })
|
||||
mediaFiles, err := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: thisFilter})
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Error retrieving artists for genre: %+v", err)
|
||||
@ -251,7 +251,7 @@ func handleGenre(matchResults map[string]string, ret []interface{}, cds *content
|
||||
}
|
||||
|
||||
for artistId := range artistsFound {
|
||||
child := contentDirectoryObject {
|
||||
child := contentDirectoryObject{
|
||||
Path: path.Join(o.Path, artistsFound[artistId]),
|
||||
Id: path.Join(o.Path, artistId),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user