Separate core model logic from top-level asset service layer functions #1991
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #1886
As a part of the audit backend PR, I noticed that we do something peculiar in the
change_asset
service layer function, which required an undesirable workaround for audit. Thechange_asset
function at its core just callsremove_asset_from_version
andadd_asset_to_version
sequentially. This achieves the desired outcome, but with the following downsides:change_asset
) contains its own set of checks and filters to ensure the asset being created/modified/destroyed is not malformed. This is largely similar between the services, but they each differ slightly. So whenremove_asset_from_version
andadd_asset_to_version
are called fromchange_asset
, they are each making checks that were already made inchange_asset
, making the overall operation inefficient.do_audit
flag being introduced intoadd_asset_to_version
andremove_asset_from_version
, to workaround this limitation.This PR separates out the core model logic from those two respective functions, allowing all of them, including
change_asset
, to utilize them. This removes the need for thedo_audit
flag, and generally cleans up the asset service layer a bit.Once #1886 is merged, this can be rebased off master and fully evaluated.