[WEB-5285] feat: enhance ChangeTrackerMixin to capture changed fields on save (#8270)

- Added an override for the save method in ChangeTrackerMixin to store changed fields before resetting tracking.
- Implemented a new method, _reset_tracked_fields, to ensure subsequent saves detect changes relative to the last saved state.
- Updated IssueComment to utilize _changes_on_save for determining changed fields, improving accuracy in tracking modifications.
This commit is contained in:
Dheeraj Kumar Ketireddy 2025-12-10 00:59:57 +05:30 committed by GitHub
parent 079a624006
commit 8bb7ebb725
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View file

@ -513,10 +513,12 @@ class IssueComment(ChangeTrackerMixin, ProjectBaseModel):
"comment_json": "description_json",
}
# Use _changes_on_save which is captured by ChangeTrackerMixin.save()
# before the tracked fields are reset
changed_fields = {
desc_field: getattr(self, comment_field)
for comment_field, desc_field in field_mapping.items()
if self.has_changed(comment_field)
if comment_field in self._changes_on_save
}
# Update description only if comment fields changed