Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Refactor tag system

Open ildyria opened this issue 6 months ago • 1 comments

This pull request introduces significant changes to the handling of tags in the application. It replaces the previous string-based tag system with a relational model using a new Tag entity. This change affects multiple parts of the codebase, including models, controllers, resources, and database interactions. The key improvements include better tag management, relational mapping between photos and tags, and enhanced query capabilities.

Tag System Overhaul:

  1. Introduction of the Tag Model:

    • A new Tag model (app/Models/Tag.php) has been added to represent tags as entities in the database. It includes methods for relational mapping with photos and a utility method Tag::from() to fetch or create tags dynamically.
  2. Relational Mapping Between Photos and Tags:

    • The Photo model now includes a tags() method to define a BelongsToMany relationship with the Tag model, replacing the previous array-based tag handling.
  3. Refactoring of Tag Album:

    • The TagAlbum model now uses the TagArrayCast class to handle tags as Tag objects instead of strings.

Controller and Resource Updates:

  1. Tag Management in Controllers:

    • Controllers such as PhotoController and AlbumController now handle tags using the Tag model, including syncing tags with photos and dynamically creating tags if they don't exist. [1] [2]
  2. Resource Representation:

    • Tags are now represented as their name in API resources like PhotoResource and TagAlbumResource. This ensures API responses are more user-friendly and consistent. [1] [2]

Query and Search Enhancements:

  1. Improved Query Handling:

    • Queries now include tags as a relation, allowing for more efficient data retrieval and filtering. This applies to various parts of the application, such as PhotoSearch and FrameController. [1] [2]
  2. Custom Query Builder for Tags:

    • A specialized TagBuilder class has been introduced to extend query capabilities for the Tag model.

These changes collectively enhance the application's ability to manage and query tags, improving both backend efficiency and frontend usability.

ildyria avatar Jun 08 '25 14:06 ildyria

Codecov Report

:x: Patch coverage is 96.51163% with 3 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.82%. Comparing base (8dd4b28) to head (de216e2). :warning: Report is 4 commits behind head on master.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 08 '25 16:06 codecov[bot]

See #3616

ildyria avatar Aug 14 '25 12:08 ildyria