mirror of
https://github.com/Dvorinka/ClubLogos.git
synced 2026-06-03 19:42:58 +00:00
push 2
This commit is contained in:
+34
-3
@@ -82,9 +82,16 @@ func searchClubsWithLogos(c *gin.Context) {
|
||||
where := ""
|
||||
args := []interface{}{}
|
||||
if q != "" {
|
||||
where = " WHERE (LOWER(club_name) LIKE ? OR id LIKE ?)"
|
||||
like := "%" + strings.ToLower(q) + "%"
|
||||
args = append(args, like, "%"+q+"%")
|
||||
normQ := normalizeClubSearchQuery(q)
|
||||
likeRaw := "%" + strings.ToLower(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 where == "" {
|
||||
@@ -254,6 +261,30 @@ func removeDiacritics(s string) string {
|
||||
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
|
||||
func getDemoClubs(query string) []Club {
|
||||
demoClubs := []Club{
|
||||
|
||||
Reference in New Issue
Block a user