Skip to content

Commit

Permalink
resolve.json: improve search quality
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
  • Loading branch information
arthurzam committed Sep 25, 2024
1 parent 30256c6 commit 4efad00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/app/handler/packages/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ func getJSONUseflag(gpackage *models.Package) Use {
Description: useflag.Description,
})
}
for _, flags := range useExpands {
for expandGroup, flags := range useExpands {
for _, flag := range flags {
useflags.UseExpand = append(useflags.UseExpand, Useflag{
Name: flag.Name,
Name: expandGroup + "_" + flag.Name,
Description: flag.Description,
})
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/app/handler/packages/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (

// Show renders a template to show a given package
func Resolve(w http.ResponseWriter, r *http.Request) {

atom := getParam(r, "atom")
gpackage := new(models.Package)
err := database.DBCon.Model(gpackage).
Where("atom LIKE ?", "%"+atom).

var gpackage models.Package
err := database.DBCon.Model(&gpackage).
Where("atom LIKE ? ", "%"+atom+"%").
OrderExpr("name <-> ?", atom).
Relation("Versions").
Relation("Versions.Masks").
Relation("Commits", func(q *pg.Query) (*pg.Query, error) {
Expand All @@ -33,9 +34,9 @@ func Resolve(w http.ResponseWriter, r *http.Request) {

sortVersionsDesc(gpackage.Versions)

versions := getJSONVersions(gpackage)
maintainers := getJSONMaintainers(gpackage)
useflags := getJSONUseflag(gpackage)
versions := getJSONVersions(&gpackage)
maintainers := getJSONMaintainers(&gpackage)
useflags := getJSONUseflag(&gpackage)

jsonPackage := Package{
Atom: gpackage.Atom,
Expand All @@ -55,7 +56,6 @@ func Resolve(w http.ResponseWriter, r *http.Request) {
}

b, err := json.Marshal(result)

if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError),
http.StatusInternalServerError)
Expand Down

0 comments on commit 4efad00

Please sign in to comment.