Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14147 Prevent logging to Change Log when no changes are made #14477

Merged
merged 6 commits into from
Dec 15, 2023

Conversation

arthanson
Copy link
Collaborator

@arthanson arthanson commented Dec 8, 2023

Fixes: #14147

Prevents an ObjectChange record from being created if there is an update and no data has changed.

Adds a CHANGELOG_SKIP_EMPTY_CHANGES config param, default False, that allows to skip the logging if no changes. i.e. the default is the old behavior.

If this flag is set, then to_objectchange can return None which needs to be checked in overriden functions. Did it this way for performance to prevent instantiating an object and serializing data if it is never going to be used.

A side-effect of this change, which should probably be default, is the last_updated field is removed from the serialized data of the changelog. The reason for this is this would be counted as a changed field when comparing the serialized records (pre / post update).

Added to feature branch as it seems a big enough feature change to be in a point release.

@arthanson arthanson changed the title DRAFT: 14147 Prevent logging to Change Log when no changes are made 14147 Prevent logging to Change Log when no changes are made Dec 12, 2023
@jeremystretch jeremystretch marked this pull request as ready for review December 12, 2023 19:51
netbox/netbox/models/features.py Outdated Show resolved Hide resolved
netbox/utilities/utils.py Outdated Show resolved Hide resolved
docs/configuration/miscellaneous.md Outdated Show resolved Hide resolved
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @arthanson!

@jeremystretch jeremystretch added this to the v3.7 milestone Dec 15, 2023
@jeremystretch jeremystretch merged commit 224d640 into feature Dec 15, 2023
8 checks passed
@jeremystretch jeremystretch deleted the 14147-no-changelog branch December 15, 2023 20:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants