Skip to content

Commit

Permalink
fix SearchReleaser not handling exact initialism matches.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Oct 14, 2024
1 parent 61020a0 commit de9185a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions assets/js/helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function titleize(text) {
"f1",
"ftp",
"hq",
"ibm",
"id",
"iso",
"la",
Expand Down
11 changes: 10 additions & 1 deletion handler/htmx/htmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,22 @@ func SearchReleaser(c echo.Context, db *sql.DB, logger *zap.SugaredLogger) error
}

lookup := []string{}
// example key and values: "tristar-ampersand-red-sector-inc": {"TRSi", "TRS", "Tristar"},
for key, values := range initialism.Initialisms() {
for _, value := range values {
name := releaser.Humanize(string(key))
if strings.EqualFold(value, slug) {
lookup = append(lookup, name)
continue
}
if strings.Contains(strings.ToLower(value), strings.ToLower(slug)) {
lookup = append(lookup, string(key))
lookup = append(lookup, name)
}
}
}
if name := releaser.Humanize(string(slug)); !strings.EqualFold(name, slug) {
lookup = append(lookup, name)
}
lookup = append(lookup, slug)
var r model.Releasers
if err := r.Similar(ctx, db, maxResults, lookup...); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion public/js/editor-artifact.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/editor-assets.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit de9185a

Please sign in to comment.