server-tools icon indicating copy to clipboard operation
server-tools copied to clipboard

[IMP] auditlog/models/rule.py: Add condition to skip logging if no fields changed in write method

Open chupaSV opened this issue 2 years ago • 1 comments

Add a condition to check if any fields have changed before creating a log entry for the "write" method. This improves performance and reduces unnecessary log entries.

chupaSV avatar Aug 01 '23 14:08 chupaSV

Great functionality. However, when the only changed field is a field of the list fields_to_exclude a log entry is still created but without any entry at the updated fields table. I see no problem to prevent log creation if those fields are changed. I changed the line changed_fields = diff.changed() - set(FIELDS_BLACKLIST) to changed_fields = diff.changed() - set(FIELDS_BLACKLIST) - set(fields_to_exclude) and it works fine.

Steps to reproduce:

  1. Go to "Rules"
  2. Add the active field of the model to "fields_to_exclude_ids"
  3. "Subscribe" the rule
  4. Archive a record of the model of the rule
  5. A log without any entry at updated fields is created

ChristophAbenthungCibex avatar May 21 '24 05:05 ChristophAbenthungCibex