Follow-up from "Change increase_usage to an instance method"
The following discussion from !85939 (merged) should be addressed:
-
@drew started a discussion: (+2 comments) This should probably go in a follow-up, for the sake of keeping the refactors ultra-clear that there's no behavioral change, but being able to consolidate this validates the class/object API change to me.
def track_monthly_usage(consumption, duration) # preload minutes usage data outside of transaction usages = [project_usage, namespace_usage].compact ::Ci::Minutes::NamespaceMonthlyUsage.transaction do usages.each { |usage| usage.increase_usage(amount_used: consumption, shared_runners_duration: duration) } end end