diff --git a/internal/search/handle.go b/internal/search/handle.go index 744a02a1..f0d94322 100644 --- a/internal/search/handle.go +++ b/internal/search/handle.go @@ -130,13 +130,7 @@ func (c *client) Handle(ctx echo.Context) error { } ids := slice.Map(hits, func(h hit) model.SubjectID { return h.ID }) - var sf = subject.Filter{} - - if r.Filter.NSFW.Set && !r.Filter.NSFW.Value { - sf.NSFW = null.Bool{Set: true, Value: false} - } - - subjects, err := c.subjectRepo.GetByIDs(ctx.Request().Context(), ids, sf) + subjects, err := c.subjectRepo.GetByIDs(ctx.Request().Context(), ids, subject.Filter{}) if err != nil { return errgo.Wrap(err, "subjectRepo.GetByIDs") } diff --git a/internal/tag/cache_repo.go b/internal/tag/cache_repo.go index 0b85bcfa..32f3b4ba 100644 --- a/internal/tag/cache_repo.go +++ b/internal/tag/cache_repo.go @@ -28,6 +28,8 @@ import ( "github.com/bangumi/server/internal/pkg/cache" ) +const cacheTTL = time.Hour * 4 + func NewCachedRepo(c cache.RedisCache, r Repo, log *zap.Logger) CachedRepo { return cacheRepo{cache: c, repo: r, log: log.Named("subject.CachedRepo")} } @@ -89,10 +91,7 @@ func (r cacheRepo) Get(ctx context.Context, id model.SubjectID) ([]Tag, error) { return tags, err } - if e := r.cache.Set(ctx, key, cachedTags{ - ID: id, - Tags: tags, - }, time.Hour); e != nil { + if e := r.cache.Set(ctx, key, cachedTags{ID: id, Tags: tags}, cacheTTL); e != nil { r.log.Error("can't set response to cache", zap.Error(e)) } @@ -141,7 +140,7 @@ func (r cacheRepo) GetByIDs(ctx context.Context, ids []model.SubjectID) (map[mod err = r.cache.Set(ctx, cachekey.SubjectMetaTag(id), cachedTags{ ID: id, Tags: tag, - }, time.Hour) + }, cacheTTL) if err != nil { return nil, errgo.Wrap(err, "cache.Set") }