diff --git a/internal/search/handle.go b/internal/search/handle.go index 44061308..42e88396 100644 --- a/internal/search/handle.go +++ b/internal/search/handle.go @@ -135,10 +135,17 @@ 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 idsToGetTags []model.SubjectID + for _, m := range subjects { + if m.MetaTags != "" { + idsToGetTags = append(idsToGetTags, m.ID) + } + } + + tags, err := c.tagRepo.GetByIDs(ctx.Request().Context(), idsToGetTags) + if err != nil { + return errgo.Wrap(err, "tagRepo.GetByIDs") + } var data = make([]ReponseSubject, 0, len(subjects)) for _, id := range ids { @@ -146,8 +153,10 @@ func (c *client) Handle(ctx echo.Context) error { if !ok { continue } - // metaTags := tags[id] - var metaTags []tag.Tag + metaTags := tags[id] + if metaTags == nil { + metaTags = []tag.Tag{} + } for _, t := range strings.Split(s.MetaTags, " ") { metaTags = append(metaTags, tag.Tag{Name: t, Count: 1})