Skip to content

Commit a4e47c0

Browse files
author
F1923795 Cassio Lamarck Silva Freitas
committed
fix permanent 400 in request with fuzzy search
1 parent 26adf45 commit a4e47c0

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

schema/schema.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ type GameSearchRequestDto struct {
154154
Query string `json:"query"`
155155
Category *[]int `json:"category,omitempty"`
156156
Status *[]int `json:"status,omitempty"`
157-
Genres *[]string `json:"genres"`
158-
Themes *[]string `json:"themes"`
159-
Platforms *[]string `json:"platforms"`
160157
Limit *int `json:"limit,omitempty"`
161158
Page *int `json:"page,omitempty"`
162159
Profile *bool `json:"profile,omitempty"`

search/games/search_games.go

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,63 +26,15 @@ func ValidateGameSearchRequest(dtoBytes []byte) (*schema.GameSearchRequestDto, e
2626
// buildManticoreMatchString
2727
// Builds the string to be inserted in the 'match' SQL function.
2828
func buildManticoreMatchString(dto *schema.GameSearchRequestDto) (string, error) {
29-
var matchString string
3029
query := &dto.Query
31-
genres := dto.Genres
32-
themes := dto.Themes
33-
platforms := dto.Platforms
3430

3531
if query == nil {
3632
return "", errors.New("query parameter empty")
3733
}
3834

3935
parsedQuery := parseQuery(*query)
4036

41-
// Matches name and alternative_names fields
42-
matchString = fmt.Sprintf("@(name,alternative_names) %s", parsedQuery)
43-
var genresMatchString = ""
44-
var themesMatchString = ""
45-
var platformsMatchString = ""
46-
47-
if genres != nil && len(*genres) > 0 {
48-
genresMatchString = " @genres_names "
49-
for i, v := range *genres {
50-
if i > 0 {
51-
genresMatchString = fmt.Sprintf("%s|%s", genresMatchString, v)
52-
continue
53-
}
54-
genresMatchString = fmt.Sprintf("%s%s", genresMatchString, v)
55-
}
56-
57-
}
58-
59-
if themes != nil && len(*themes) > 0 {
60-
themesMatchString = " @themes_names "
61-
for i, v := range *themes {
62-
if i > 0 {
63-
themesMatchString = fmt.Sprintf("%s|%s", themesMatchString, v)
64-
continue
65-
}
66-
themesMatchString = fmt.Sprintf("%s|%s", themesMatchString, v)
67-
}
68-
69-
}
70-
71-
if platforms != nil && len(*platforms) > 0 {
72-
platformsMatchString = " @(platforms_names,platforms_abbreviations) "
73-
for i, v := range *platforms {
74-
if i > 0 {
75-
platformsMatchString = fmt.Sprintf("%s|%s", platformsMatchString, v)
76-
continue
77-
}
78-
platformsMatchString = fmt.Sprintf("%s%s", platformsMatchString, v)
79-
}
80-
}
81-
82-
finalMatchString := fmt.Sprintf("%s%s%s%s", matchString, genresMatchString, themesMatchString, platformsMatchString)
83-
84-
return finalMatchString, nil
85-
37+
return parsedQuery, nil
8638
}
8739

8840
func buildManticoreFilterString(dto *schema.GameSearchRequestDto) (string, error) {

0 commit comments

Comments
 (0)