Skip to content

Commit

Permalink
fix: ignore empty tag on search (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored Nov 26, 2024
1 parent b5a9fe0 commit 7f56155
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 0 additions & 4 deletions internal/search/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/bangumi/server/domain/gerr"
"github.com/bangumi/server/internal/model"
"github.com/bangumi/server/internal/subject"
"github.com/bangumi/server/internal/tag"
)

// New provide a search app is AppConfig.MeiliSearchURL is empty string, return nope search client.
Expand All @@ -48,7 +47,6 @@ import (
func New(
cfg config.AppConfig,
subjectRepo subject.Repo,
tagRepo tag.CachedRepo,
log *zap.Logger,
query *query.Query,
) (Client, error) {
Expand Down Expand Up @@ -80,7 +78,6 @@ func New(
subjectIndex: meili.Index("subjects"),
log: log.Named("search"),
subjectRepo: subjectRepo,
tagRepo: tagRepo,
}

if cfg.AppType != config.AppTypeCanal {
Expand Down Expand Up @@ -139,7 +136,6 @@ func (c *client) canalInit(cfg config.AppConfig) error {

type client struct {
subjectRepo subject.Repo
tagRepo tag.CachedRepo
meili meilisearch.ServiceManager
q *query.Query
subjectIndex meilisearch.IndexManager
Expand Down
9 changes: 3 additions & 6 deletions internal/search/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,18 @@ func (c *client) Handle(ctx echo.Context) error {
return errgo.Wrap(err, "subjectRepo.GetByIDs")
}

// tags, err := c.tagRepo.GetByIDs(ctx.Request().Context(), ids)
// if err != nil {
// return errgo.Wrap(err, "tagRepo.GetByIDs")
// }

var data = make([]ReponseSubject, 0, len(subjects))
for _, id := range ids {
s, ok := subjects[id]
if !ok {
continue
}
// metaTags := tags[id]
var metaTags []tag.Tag

for _, t := range strings.Split(s.MetaTags, " ") {
if t == "" {
continue
}
metaTags = append(metaTags, tag.Tag{Name: t, Count: 1})
}

Expand Down

0 comments on commit 7f56155

Please sign in to comment.