Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag relationship processing errors #1156

Merged
merged 3 commits into from
Oct 28, 2024
Merged

Fix tag relationship processing errors #1156

merged 3 commits into from
Oct 28, 2024

Conversation

sosyz
Copy link
Member

@sosyz sosyz commented Oct 27, 2024

Description

This PR addresses three issues:

  1. Optimizes the performance of checking for new tags.
  2. Fixes an issue where tag relationships had incorrect status when enabled.
  3. Adds status filtering when updating tag relationships.

These changes are related to the bug reported in #1144

Changes

  1. Optimized HasNewTag function in internal/service/tag_common/tag_common.go:

    • Replaced map[string]bool with map[string]struct{} for better memory efficiency.
    • Simplified the logic to check for new tags, reducing unnecessary iterations.
  2. Fixed tag relationship status when enabling:

    • Added logic to consider the question's status (hidden/visible) when restoring tag relationships.
  3. Added status filtering when updating tag relationships:

    • Implemented filtering to exclude deleted data when restoring hidden tag relationships.

Testing

Please test the following scenarios:

  1. Unlisting a question with multiple tags
  2. Editing an unlisted question (removing and adding tags)
  3. Listing the question again

Verify that:

  • Removed tags are not displayed after listing the question
  • Tag relationships are correctly maintained when changing list/unlist status
  • Performance is improved for operations involving tag checks

Additional Notes

This PR aims to resolve the issues mentioned in #1144 and improve overall tag handling in the system. Please review and provide feedback if any further changes are needed.

@sosyz sosyz requested a review from LinkinStars October 27, 2024 05:42
@LinkinStars LinkinStars added this to the v1.4.2 milestone Oct 28, 2024
@LinkinStars
Copy link
Member

I tested it and the bug has been fixed. The optimization of the code is also great.

@LinkinStars LinkinStars merged commit 7c677f3 into apache:dev Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants