Follow-up from "Create CI component usage record when component is included in pipeline"
The following discussion from !148216 (merged) should be addressed:
-
@furkanayhan started a discussion: (+1 comment) @lma-git Have you considered this?
if component_usage.save ServiceResponse.success(message: 'Usage recorded') else errors = component_usage.errors if errors.size == 1 && errors.first.type == :taken # Only unique validation failed ServiceResponse.success(message: 'Usage already recorded for today') else ServiceResponse.error(message: errors.full_messages.join(', ')) end end
Proposal
Minor code refactoring to reduce a line of code