Skip to content

Refactor tag system #3424

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Refactor tag system #3424

wants to merge 4 commits into from

Conversation

ildyria
Copy link
Member

@ildyria ildyria commented Jun 8, 2025

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 ildyria requested a review from a team as a code owner June 8, 2025 14:43
@ildyria ildyria added the Review: medium Medium review expected: not many files, some attention to details required. label Jun 8, 2025
Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 94.28571% with 4 lines in your changes missing coverage. Please review.

Project coverage is 86.79%. Comparing base (8562bdb) to head (35e6770).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review: medium Medium review expected: not many files, some attention to details required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant