Skip to content

Fix tags to fix search functionality #81

@ploiu

Description

@ploiu

search right now for tags works for simple stuff, but weird edge cases don't work. Search is performed in a roundabout way to heavily reduce io time.

Reducing IO time on search is incredibly important. However, the current search is too brittle and too hard to understand.

these changes are needed:

database

  • Files_Tags table needs a column named inherited_from to indicate if the tag is inherited from a folder. The value of the column is the id of the folder that tag is inherited from. nullable. add a unique constraint on tag title and file id.
  • Folders_Tags table needs a column named inherited_from to indicate if the tag is inherited from a folder. The value of the column is the id of the folder that tag is inherited from. nullable. add a unique constraint on tag title and folder id.

process changes

add direct tag to folder

  • whenever a folder gets a new direct tag, update all child folders to inherit that tag in the database. If a child folder already has that tag (either already inherited or directly has it), skip adding it
  • whenever a folder gets a new direct tag, update all direct child files to inherit that tag. If the child file already has that tag (either already inherited or directly has it), skip adding it
  • prevent a folder from having a tag directly added to it if it already has the tag (directly or inherited)

folder inherits tag

  • when a folder newly-inherits a tag, update all child folders to also inherit that tag, so long as it does not already have it (via inheriting or direct tag ownership)
  • when a folder newly-inherits a tag, update all direct child files to also inherit that tag, so long as it does not already have it

folder removes a tag

  • when a folder has a direct tag removed from it, remove that tag from all folders that inherit it
  • when a folder has a direct tag removed from it, remove that tag from all files that inherit it

folder is moved

  • when a folder is moved to a new parent, remove all inherited tags, and apply all tags that should be inherited from the parent folder chain. This should trigger inheritance for all child folders and direct files as well

search

search by tag should be simplified to look at the tags directly on a file, instead of having to flatten and deduplicate parent folders based on tags

jobs

database v6 needs to be created, which will automatically apply all inheritance rules listed above

notes:

  • null inherited_from field means that folder/file has it directly
  • do not change any tests surrounding search functionality. Use those tests to make sure your code isn't broken
  • be sure to update models and openapi docs

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions