mirror of
https://github.com/Dvorinka/ClubLogos.git
synced 2026-06-05 04:22:56 +00:00
push 2
This commit is contained in:
+34
-3
@@ -82,9 +82,16 @@ func searchClubsWithLogos(c *gin.Context) {
|
|||||||
where := ""
|
where := ""
|
||||||
args := []interface{}{}
|
args := []interface{}{}
|
||||||
if q != "" {
|
if q != "" {
|
||||||
where = " WHERE (LOWER(club_name) LIKE ? OR id LIKE ?)"
|
normQ := normalizeClubSearchQuery(q)
|
||||||
like := "%" + strings.ToLower(q) + "%"
|
likeRaw := "%" + strings.ToLower(q) + "%"
|
||||||
args = append(args, like, "%"+q+"%")
|
if normQ != "" && normQ != q {
|
||||||
|
likeNorm := "%" + strings.ToLower(normQ) + "%"
|
||||||
|
where = " WHERE ((LOWER(club_name) LIKE ? OR LOWER(club_name) LIKE ?) OR id LIKE ?)"
|
||||||
|
args = append(args, likeRaw, likeNorm, "%"+q+"%")
|
||||||
|
} else {
|
||||||
|
where = " WHERE (LOWER(club_name) LIKE ? OR id LIKE ?)"
|
||||||
|
args = append(args, likeRaw, "%"+q+"%")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if sport != "" && sport != "all" {
|
if sport != "" && sport != "all" {
|
||||||
if where == "" {
|
if where == "" {
|
||||||
@@ -254,6 +261,30 @@ func removeDiacritics(s string) string {
|
|||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeClubSearchQuery(q string) string {
|
||||||
|
s := strings.TrimSpace(q)
|
||||||
|
if s == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
lower := strings.ToLower(s)
|
||||||
|
parts := strings.Fields(lower)
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
switch parts[0] {
|
||||||
|
case "fk":
|
||||||
|
parts[0] = "fotbalový klub"
|
||||||
|
case "tj":
|
||||||
|
parts[0] = "tělovýchovná jednota"
|
||||||
|
case "sk":
|
||||||
|
parts[0] = "sportovní klub"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(parts, " ")
|
||||||
|
}
|
||||||
|
|
||||||
// Demo data fallback
|
// Demo data fallback
|
||||||
func getDemoClubs(query string) []Club {
|
func getDemoClubs(query string) []Club {
|
||||||
demoClubs := []Club{
|
demoClubs := []Club{
|
||||||
|
|||||||
Reference in New Issue
Block a user