This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git


The following commit(s) were added to refs/heads/dev by this push:
     new e0957c0a Revert "perf: optimize tag has new tag check"
e0957c0a is described below

commit e0957c0a0d179f674c432ffa6b5fd1ccdcb247dc
Author: Sonui <[email protected]>
AuthorDate: Wed Feb 12 07:11:51 2025 +0800

    Revert "perf: optimize tag has new tag check"
    
    This reverts commit 5af69352b546a21ebabe7a570c355e3f6b995bb1.
---
 internal/service/tag_common/tag_common.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/internal/service/tag_common/tag_common.go 
b/internal/service/tag_common/tag_common.go
index e5c136c3..d99795d9 100644
--- a/internal/service/tag_common/tag_common.go
+++ b/internal/service/tag_common/tag_common.go
@@ -291,18 +291,24 @@ func (ts *TagCommonService) ExistRecommend(ctx 
context.Context, tags []*schema.T
 
 func (ts *TagCommonService) HasNewTag(ctx context.Context, tags 
[]*schema.TagItem) (bool, error) {
        tagNames := make([]string, 0)
-       tagMap := make(map[string]struct{})
+       tagMap := make(map[string]bool)
        for _, item := range tags {
                item.SlugName = strings.ReplaceAll(item.SlugName, " ", "-")
                tagNames = append(tagNames, item.SlugName)
-               tagMap[item.SlugName] = struct{}{}
+               tagMap[item.SlugName] = false
        }
        list, err := ts.GetTagListByNames(ctx, tagNames)
        if err != nil {
                return true, err
        }
        for _, item := range list {
-               if _, ok := tagMap[item.SlugName]; !ok {
+               _, ok := tagMap[item.SlugName]
+               if ok {
+                       tagMap[item.SlugName] = true
+               }
+       }
+       for _, has := range tagMap {
+               if !has {
                        return true, nil
                }
        }

Reply via email to