Skip to content

Commit

Permalink
fix(search): nsfw response
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Jun 30, 2024
1 parent b7a3b8d commit af87d8f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions internal/search/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@ func (c *client) Handle(ctx echo.Context) error {
}
ids := slice.Map(hits, func(h hit) model.SubjectID { return h.ID })

subjects, err := c.subjectRepo.GetByIDs(ctx.Request().Context(), ids, subject.Filter{NSFW: r.Filter.NSFW})
subjects, err := c.subjectRepo.GetByIDs(ctx.Request().Context(), ids, subject.Filter{})
if err != nil {
return errgo.Wrap(err, "subjectRepo.GetByIDs")
}

data := slice.Map(ids, func(id model.SubjectID) ReponseSubject {
s := subjects[id]
var data = make([]ReponseSubject, 0, len(subjects))
for _, id := range ids {
s, ok := subjects[id]
if !ok {
continue
}

return ReponseSubject{
data = append(data, ReponseSubject{
Date: s.Date,
Image: res.SubjectImage(s.Image).Large,
Type: s.TypeID,
Expand All @@ -131,8 +135,9 @@ func (c *client) Handle(ctx echo.Context) error {
Score: s.Rating.Score,
ID: s.ID,
Rank: s.Rating.Rank,
}
})
})

}

Check failure on line 140 in internal/search/handle.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)

return ctx.JSON(http.StatusOK, res.Paged{
Data: data,
Expand Down

0 comments on commit af87d8f

Please # to comment.