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

Fixed unaccepted assets report memory exhaustion bug, Optimized query #16036

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Godmartinz
Copy link
Collaborator

Optimized the unaccepted asset reports query slightly. Should fix the memory exhaustion issue. but there is room for improvement with the amount of models loaded.

@Godmartinz Godmartinz requested a review from snipe as a code owner January 7, 2025 23:12
@Godmartinz Godmartinz requested review from marcusmoore, spencerrlongg and snipe and removed request for snipe January 7, 2025 23:12
Copy link

what-the-diff bot commented Jan 7, 2025

PR Summary

  • Improvement on Reports Management
    It includes an update on ReportsController that brings a few changes:

    • Introduction of new models including 'Company' and 'MorphTo' which should improve how data is managed behind-the-scenes.
    • Refinement of the asset acceptance report query. It now uses a single query object that can conditionally include trashed records, making data retrieval more efficient.
    • Enhancement in the loading of relationships in the system. The checkout process now employs an improved syntax for fetching related data, making this operation faster and more reliable.
  • Correction in CheckoutAcceptance Model
    We have fixed an inconsistency in the CheckoutAcceptance model. The method in question, checkoutable, now refers to the correct namespace in its type hint. This results in a more accurate and reliable reference, thus improving the stability of the checkout operation.

  • Upgrade to AssetObserver
    The Observer in charge of monitoring Assets has been tweaked to better handle situations where certain settings might be unavailable. Specifically, the retrieval of the prefix setting now defaults to an empty string if the setting is null, therefore ensuring the application remains stable even when expected data is not available.

@snipe snipe requested a review from uberbrady January 9, 2025 16:10
Comment on lines +1118 to +1122
$query->morphWith([
AssetModel::class => ['model'],
Company::class => ['company'],
Asset::class => ['assignedTo'],
])->with('model.category');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't had a chance to check this out yet but want to note that morphWith is the documented way to eager load morphTo relationships. It looks weird but we landed on that while pairing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants