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

Introduce support for audited_class setting per model #735

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

amkisko
Copy link

@amkisko amkisko commented Oct 29, 2024

Done:

  • test coverage for all changes in this PR
  • README updated accordingly
  • generators updated to support custom table name

Background:

  • single table might become problematic for large amount of logs/audits
  • partitioning of audits table leads to other problems to solve
  • having full separation of audits tables per model gives more flexibility
  • keeping it strict and as much verbose as needed
  • compatibility with previous behavior required
  • looked at Define audit_class per model #641

@amkisko
Copy link
Author

amkisko commented Nov 6, 2024

@danielmorrison Hey! These changes has been tested in production for past two weeks, no issues found so far, works quite well.

@amkisko
Copy link
Author

amkisko commented Nov 11, 2024

@danielmorrison CI tests are all actually green, there is this "missing coverage" assessment, which does not return anything locally (meaning that all changes are covered), but here it returns different results depending on Rails version and database driver.

@amkisko
Copy link
Author

amkisko commented Nov 11, 2024

Any suggestions how to replicate it locally?

@amkisko
Copy link
Author

amkisko commented Nov 20, 2024

There might be a bug introduced due to custom serializer, we have not figured out a test case for this one yet: undefined method 'merge' for an instance of String (NoMethodError) combine_target.audited_changes = audits_to_combine.pluck(:audited_changes).reduce(&:merge)

@amkisko
Copy link
Author

amkisko commented Nov 27, 2024

@danielmorrison I switched from .pluck(:audited_changes) to .map(&:audited_changes) -- assumption here is that something has changed in Rails 7 in relation to column value serialization (could not find any evidences yet). It should not bring impact on performance as combine most probably have only few records during single request (basically previous request already did combine if max threshold crossed), but it's more clear what it does, pluck on ActiveRecord proxy does select of raw value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants