Skip to content

Update print inventory view with indirect assignments table#18629

Open
Godmartinz wants to merge 12 commits intogrokability:developfrom
Godmartinz:update-print-invtentory-view-with-assigned2assets
Open

Update print inventory view with indirect assignments table#18629
Godmartinz wants to merge 12 commits intogrokability:developfrom
Godmartinz:update-print-invtentory-view-with-assigned2assets

Conversation

@Godmartinz
Copy link
Copy Markdown
Member

@Godmartinz Godmartinz commented Mar 4, 2026

This adds a table for Indirect Assignments, assets/accessories/licenses/components assigned to assets that are assigned to users, to the print inventory view

image

@Godmartinz Godmartinz requested a review from snipe as a code owner March 4, 2026 00:13
@Godmartinz Godmartinz requested review from marcusmoore and removed request for snipe March 4, 2026 00:13
@Godmartinz Godmartinz changed the title Update print invtentory view with indirect Assignments table Update print inventory view with indirect Assignments table Mar 4, 2026
@Godmartinz Godmartinz changed the title Update print inventory view with indirect Assignments table Update print inventory view with indirect assignments table Mar 4, 2026
@Godmartinz Godmartinz requested a review from snipe March 4, 2026 00:14
@marcusmoore
Copy link
Copy Markdown
Collaborator

@Godmartinz I think the failing test needs to be updated.

Copy link
Copy Markdown
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.

There's a couple small fixes I outlined but I also noticed query count creeping up when more assignments exist. There's an n+1 in there somewhere.

It's kind of out of the scope of this PR but throwing \Illuminate\Database\EloquentModel::preventLazyLoading(); at the top of the controller method and reloading the page shows directLicenses.category is not eager loaded.

->withTrashed()
->first();

$indirectItemsCount = $user?->assets?->flatMap->assignedAssets->count() + $user?->assets?->flatMap->components->count() + $user?->assets?->flatMap->licenses->count() + $user?->assets?->flatMap->assignedAccessories->count();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This caught my eye. I wonder if there is a way to have the database do the counting. I'm not sure off the top of my head.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didnt find a good/better solution to this.. this was less lines. But I am open to suggestions.

@Godmartinz
Copy link
Copy Markdown
Member Author

handling your requests @marcusmoore, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants