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

Added better handling of information of asset history #13485

Merged
merged 3 commits into from
Aug 22, 2023

Conversation

Godmartinz
Copy link
Collaborator

@Godmartinz Godmartinz commented Aug 17, 2023

Description

This adds changedInfo() to the action log transformer, which will interpret changes in a more readable way.

array keys have been renamed to be more readable (e.g rtd_location_id is now Default Location) in the History tab of an asset. This information will be displayed if you edit/update a single asset or multiple assets at once.

If an asset never had a supplier, default location, company, or location already assigned to it, it will be noted as 'unassigned' (example below). If supplier, default location, company, or location are removed it will go back to unassigned as well.

Before:
image

After:
image

Removed the Supplier:
image

Fixes #sc-14441

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • PHP version:
  • MySQL version
  • Webserver version
  • OS version

Checklist:

@what-the-diff
Copy link

what-the-diff bot commented Aug 17, 2023

PR Summary

  • Introduction of New Models
    This PR introduces four new data models: 'Company', 'Supplier', 'Location', and 'AssetModel'. These new models enhance the system's ability to organize and manage data.

  • Enhancements to Asset History View
    A new function named changedInfo has been added. It improves the user experience by transforming id-values of changed attributes into human-readable names, particularly in the Asset's history view. This change makes it more straightforward to understand the modifications over time.

Copy link
Collaborator

@spencerrlongg spencerrlongg left a comment

Choose a reason for hiding this comment

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

I was trying to come up with a way to check for camel case or snake case and just transform into title case with spaces, but I can't see how that'd work with the translation strings, so looks good to me!

@Godmartinz
Copy link
Collaborator Author

Godmartinz commented Aug 21, 2023

added id to the info as requested @snipe 🙂 image

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

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

Looks good!

One thing to consider is that we're not eager loading the related data (location, asset model, company, or supplier) so we're running more queries than necessary but I don't think we can easily eager load them in the transformer (that should happen before it hits the transformer).

I'm just pointing that out. I don't think it holds back this PR but is something we'll probably want to address in the future.

@snipe
Copy link
Owner

snipe commented Aug 22, 2023

This looks great - thank you, @Godmartinz!

@snipe snipe merged commit 303b45c into snipe:develop Aug 22, 2023
@snipe
Copy link
Owner

snipe commented Aug 22, 2023

@Godmartinz When testing this locally, I'm getting a 500 on history:

[2023-08-22 05:01:23] local.ERROR: ErrorException: Trying to get property 'name' of non-object in /Users/snipe/Sites/snipe-it/snipe-it/app/Http/Transformers/ActionlogsTransformer.php:162

(I just changed the serial number, nothing else)

Please make this your top priority today. I can't merge to master until we've got this handled, or I'll have to cherry pick this merge out.

@snipe
Copy link
Owner

snipe commented Aug 22, 2023

(Also, whatever the issue is here, it would probably trigger elsewhere in the new code, so please check) TY!

@snipe
Copy link
Owner

snipe commented Aug 22, 2023

I also wonder what the query impact here might be - none of those model/company/etc queries are being eager/lazy loaded, so in the Activity Report, with many records displayed, that could be pretty hairy. Right now, I'd just like the 500 to be mitigated, but we should probably revisit this soon and make sure we're checking query counts, etc on the Activity Report page

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.

4 participants