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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So 2 things
Type is reserved for STI to just taking the type from MiqRequest is going to be an issue. If you're going to set a
:type
column it should match a sub-class ofServiceOrder
so something like if MiqRequest isServiceTemplateProvisionRequest
then ServiceOrder would becomeServiceProvisionOrder
andServiceTemplateTransformationPlanRequest
=>ServiceTransformationOrder
Updating for every service_order isn't very efficient, it'd be much better to group_by miq_request type and do an update_all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That yields an array of all the types, right? (When there are multiple requests.)
Possibly something like
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think..
gives you the right list, so you can transform it into a single update, and it should mostly work.
(No idea how to say that in rails-speak though :).)
We may want to clear any types with a comma after though. (And I guess not use
type
but something likerequest_type
?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrare Ok, we don't want STI here, so I've changed the column to
request_type
as per @himdel's suggestion. It's now a sorted and comma-joined string in the event there is more than one request type.If there's a more efficient way of doing this update I think I will need a little help putting it together.