Skip to content

Conversation

TheBobBobs
Copy link
Contributor

Summary

Add method get_tag_hierarchy to Library that returns a dict[TagId, list[ParentId]] and dict[TagId, Tag] containing every tag in the hierarchy. Update FieldContainers to use this new method.

Currently all places that call Library.tag_display_name already have the Tag object so we don't need to fetch it from db.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@TheBobBobs TheBobBobs force-pushed the perf/preview_panel branch from 4ef7c13 to 59460e4 Compare May 29, 2025 01:08
@CyanVoxel CyanVoxel added TagStudio: Search The TagStudio search engine Type: Performance An issue or change related to performance Status: Review Needed A review of this is needed labels Jun 4, 2025
@Computerdores Computerdores self-requested a review June 5, 2025 21:01
@CyanVoxel CyanVoxel moved this to 👀 In review in TagStudio Development Aug 29, 2025
@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Aug 29, 2025
@CyanVoxel CyanVoxel added this to the Alpha v9.5.4 milestone Aug 29, 2025
Copy link
Member

@CyanVoxel CyanVoxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for getting around to this one so late. Everything seems to be working as intended and I'm glad that the tag hierarchy logic is now finally back into its own method. Thank you for working on this, and great changes!

Copy link
Member

@CyanVoxel CyanVoxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to backtrack on this, but it appears that this conflicts with a recent bugfix we had to correct an issue where the parent_id and child_id columns were erroneously flipped in the tag_parents table (#998). I attempted to update the logic in get_tag_hierarchy() and get_tag_categories(), but I'm not as familiar with these changes compared to the old code and wasn't able to get it working on my own. This also illuminated some quirks in the logic of get_tag_hierarchy() that resulted in the issue propagating and becoming more difficult to track down.
Would you mind seeing if you can update this to the latest code on main?

Comment on lines +1516 to +1519
for tag in tags:
all_tags[tag.id] = tag
for tag in all_tags.values():
tag.parent_tags = {all_tags[p] for p in all_tag_parents.get(tag.id, [])}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning Tag objects with overwritten parent data resulted in the conflict issue propagating further in the UI stack, including flipping the tag's parents with its children in the BuildTagPanel due to the UI sharing that same "tainted" Tag object. While this shouldn't be an issue when the logic if flipped to match main, it still presents the question of whether or not this may mask further issues in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TagStudio: Search The TagStudio search engine Type: Performance An issue or change related to performance
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

2 participants