public-activity / public_activity

Easy activity tracking for models - similar to Github's Public Activity
MIT License
2.97k stars 336 forks source link

Possibility to prepare a batch of activities to be saved later #343

Closed luminouw closed 2 years ago

luminouw commented 5 years ago

Hi there,

we're using your gem to track creation and modifications of DNS objects in a database. We just implemented a feature to allow a user to import a lot of records at the same time. When creating a record by hand, we call the create_activity method by hand on the newly created object and it works fine. Now we'd like to have the same behavior when a user imports a batch of records (let's say 500), except looping over the 500 new objects and calling create_activity on each of them isn't really optimized (meaning 500 inserts for 500 activities).

Do you think implementing a new method, let's say build_activity or prepare_activity to have the activity object just in-memory would be doable ? This way we could just prepare a bunch of activities and mass-imports them in one call into the database.

Thank you : )

pokonski commented 2 years ago

You should create such activity manually, then - after importing all records. Not rely on callbacks provided.