Only track subscription history when applicable
What does this MR do and why?
This MR modifies when we create a GitlabSubscriptionHistory
record during GitlabSubscription
updates.
Previously, we would create a record whenever any attribute changed on the GitlabSubscription
, but we only track certain attributes, so we risk potentially creating a bunch of GitlabSubscriptionHistory
records unnecessarily.
The list of tracked attributes can be found in GitlabSubscription::TRACKED_ATTRIBUTES
- we are only interested in having changes to these attributes stored in the histories table, therefore we only need to create a record when one of those changes.
Refs #393618 (closed)
How to set up and validate locally
- Checkout
master
(i.e. not this MR) - Find a
GitlabSubscription
recordgs = GitlabSubscription.last
- Confirm history record is created for an untracked attribute change:
GitlabSubscriptionHistory.where(namespace_id: gs.namespace_id).count => 0 gs.update(last_seat_refresh_at: Time.current) GitlabSubscriptionHistory.where(namespace_id: gs.namespace_id).count => 1
- Checkout this branch
vij-tweak-gitlab-subscription-log
- Perform the test above again (remembering to
reload!
the console) and confirm no history record is created
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vijay Hawoldar