From e9777005355a35867c259f748b005e6730491136 Mon Sep 17 00:00:00 2001 From: Rorical <46294886+Rorical@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:44:36 +0100 Subject: [PATCH] fix: one tag match only --- common/database/operations/illust.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/database/operations/illust.go b/common/database/operations/illust.go index 337cb9d..92bd324 100644 --- a/common/database/operations/illust.go +++ b/common/database/operations/illust.go @@ -376,11 +376,17 @@ func (ops *DatabaseOperations) SearchIllust(ctx context.Context, keyword string, func (ops *DatabaseOperations) QueryIllustsByTags(ctx context.Context, tags []string, page int64, limit int64, sortpopularity bool, sortdate bool, resultbanned bool) ([]models.Illust, error) { var results []models.Illust + var filter interface{} + + if len(tags) > 1 { + filter = bson.M{"$in": tags} + } else { + filter = tags[0] + } + query := bson.M{ - "tags.name": bson.M{ - "$in": tags, - }, - "banned": false, + "tags.name": filter, + "banned": false, } if resultbanned { query["banned"] = true