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

Avoid unnecessarily hydrating models on asset model show page #14164

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

marcusmoore
Copy link
Collaborator

@marcusmoore marcusmoore commented Jan 25, 2024

Description

This PR avoids hydrating models that are only used for displaying the related count on the asset model show page.

CleanShot 2024-01-24 at 16 17 06@2x

Before:
CleanShot 2024-01-24 at 16 17 20@2x

After:
CleanShot 2024-01-24 at 16 17 47@2x

(hydrated model count is being displayed in debugbar)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copy link

what-the-diff bot commented Jan 25, 2024

PR Summary

  • Added New Method to AssetModelsController
    The 'AssetModelsController' has received an update to improve efficiency. We've added a new method, referred to as 'withCount('assets')'. This is now part of the 'show' function within the class. This method is designed to rapidly count the total number of assets linked with a specific model.

  • Updated Display Condition in View Blade
    We've also made alterations to the conditions used to display the count of assets in 'view.blade.php'. Before, it used to show the asset count only when $model->assets->count() > 0; that is, only when there were more than zero assets associated with the model. Now, it has been optimised to display the asset count when $model->assets_count > 0. This change brings a quicker response time and an improved user interface experience.

@snipe snipe merged commit 45b253a into snipe:develop Jan 25, 2024
8 checks passed
@marcusmoore marcusmoore changed the title Avoid unnecessarily hydrating models on asset show page Avoid unnecessarily hydrating models on asset model show page Jan 25, 2024
@marcusmoore marcusmoore deleted the bug/sc-20686 branch January 25, 2024 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants