only store differing unidecode and search both cols
This commit is contained in:
@@ -39,7 +39,11 @@ var coverFilenames = map[string]struct{}{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decoded(in string) string {
|
func decoded(in string) string {
|
||||||
return unidecode.Unidecode(in)
|
result := unidecode.Unidecode(in)
|
||||||
|
if result == in {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
type Scanner struct {
|
type Scanner struct {
|
||||||
|
|||||||
@@ -166,8 +166,11 @@ func (c *Controller) SearchTwo(w http.ResponseWriter, r *http.Request) {
|
|||||||
// search "artists"
|
// search "artists"
|
||||||
var artists []*model.Album
|
var artists []*model.Album
|
||||||
c.DB.
|
c.DB.
|
||||||
Where("parent_id = 1 "+
|
Where(`
|
||||||
"AND (right_path || right_path_u_dec) LIKE ?", query).
|
parent_id = 1
|
||||||
|
AND (right_path LIKE ? AND
|
||||||
|
right_path_u_dec LIKE ?)
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "artistOffset", 0)).
|
Offset(getIntParamOr(r, "artistOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "artistCount", 20)).
|
Limit(getIntParamOr(r, "artistCount", 20)).
|
||||||
Find(&artists)
|
Find(&artists)
|
||||||
@@ -179,8 +182,11 @@ func (c *Controller) SearchTwo(w http.ResponseWriter, r *http.Request) {
|
|||||||
// search "albums"
|
// search "albums"
|
||||||
var albums []*model.Album
|
var albums []*model.Album
|
||||||
c.DB.
|
c.DB.
|
||||||
Where("tag_artist_id IS NOT NULL "+
|
Where(`
|
||||||
"AND (right_path || right_path_u_dec) LIKE ?", query).
|
tag_artist_id IS NOT NULL
|
||||||
|
AND (right_path LIKE ? AND
|
||||||
|
right_path_u_dec LIKE ?)
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "albumOffset", 0)).
|
Offset(getIntParamOr(r, "albumOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "albumCount", 20)).
|
Limit(getIntParamOr(r, "albumCount", 20)).
|
||||||
Find(&albums)
|
Find(&albums)
|
||||||
@@ -192,7 +198,10 @@ func (c *Controller) SearchTwo(w http.ResponseWriter, r *http.Request) {
|
|||||||
var tracks []*model.Track
|
var tracks []*model.Track
|
||||||
c.DB.
|
c.DB.
|
||||||
Preload("Album").
|
Preload("Album").
|
||||||
Where("(filename || filename_u_dec) LIKE ?", query).
|
Where(`
|
||||||
|
filename LIKE ? AND
|
||||||
|
filename_u_dec LIKE ?
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "songOffset", 0)).
|
Offset(getIntParamOr(r, "songOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "songCount", 20)).
|
Limit(getIntParamOr(r, "songCount", 20)).
|
||||||
Find(&tracks)
|
Find(&tracks)
|
||||||
|
|||||||
@@ -167,7 +167,10 @@ func (c *Controller) SearchThree(w http.ResponseWriter, r *http.Request) {
|
|||||||
// search "artists"
|
// search "artists"
|
||||||
var artists []*model.Artist
|
var artists []*model.Artist
|
||||||
c.DB.
|
c.DB.
|
||||||
Where("(name || name_u_dec) LIKE ?", query).
|
Where(`
|
||||||
|
name LIKE ? AND
|
||||||
|
name_u_dec LIKE ?
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "artistOffset", 0)).
|
Offset(getIntParamOr(r, "artistOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "artistCount", 20)).
|
Limit(getIntParamOr(r, "artistCount", 20)).
|
||||||
Find(&artists)
|
Find(&artists)
|
||||||
@@ -180,7 +183,10 @@ func (c *Controller) SearchThree(w http.ResponseWriter, r *http.Request) {
|
|||||||
var albums []*model.Album
|
var albums []*model.Album
|
||||||
c.DB.
|
c.DB.
|
||||||
Preload("TagArtist").
|
Preload("TagArtist").
|
||||||
Where("(tag_title || tag_title_u_dec) LIKE ?", query).
|
Where(`
|
||||||
|
tag_title LIKE ? AND
|
||||||
|
tag_title_u_dec LIKE ?
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "albumOffset", 0)).
|
Offset(getIntParamOr(r, "albumOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "albumCount", 20)).
|
Limit(getIntParamOr(r, "albumCount", 20)).
|
||||||
Find(&albums)
|
Find(&albums)
|
||||||
@@ -193,7 +199,10 @@ func (c *Controller) SearchThree(w http.ResponseWriter, r *http.Request) {
|
|||||||
var tracks []*model.Track
|
var tracks []*model.Track
|
||||||
c.DB.
|
c.DB.
|
||||||
Preload("Album").
|
Preload("Album").
|
||||||
Where("(tag_title || tag_title_u_dec) LIKE ?", query).
|
Where(`
|
||||||
|
tag_title LIKE ? AND
|
||||||
|
tag_title_u_dec LIKE ?
|
||||||
|
`, query, query).
|
||||||
Offset(getIntParamOr(r, "songOffset", 0)).
|
Offset(getIntParamOr(r, "songOffset", 0)).
|
||||||
Limit(getIntParamOr(r, "songCount", 20)).
|
Limit(getIntParamOr(r, "songCount", 20)).
|
||||||
Find(&tracks)
|
Find(&tracks)
|
||||||
|
|||||||
Reference in New Issue
Block a user