Module: EzLogsAgent::Capturers::BulkDatabaseCapturer::RelationRowCountStash
- Defined in:
- lib/ez_logs_agent/capturers/bulk_database_capturer.rb
Overview
Backfills the affected-row count on the most recently captured bulk_database event. Order of operations:
1. Customer calls Relation#delete_all (or update_all).
2. AR runs the SQL → sql.active_record fires → our AS::N
handler captures the event with row_count=payload[:row_count]
(often 0 on PG for plain DELETE).
3. delete_all's super returns the affected count to us.
4. We patch the most-recently-buffered bulk_database event's
source_data[:row_count] AND its sentinel resource_id so the
timeline shows the real number.
This is a thin shim — only the count is touched, never the SQL, context, or wire shape. If the buffer’s tail isn’t a bulk_database event for our model (e.g. AS::N skipped it), we leave it alone.
Instance Method Summary collapse
Instance Method Details
#delete_all ⇒ Object
197 198 199 200 201 |
# File 'lib/ez_logs_agent/capturers/bulk_database_capturer.rb', line 197 def delete_all result = super ::EzLogsAgent::Capturers::BulkDatabaseCapturer.backfill_row_count(result, klass) if result.is_a?(Integer) result end |
#update_all(*args, **kwargs, &block) ⇒ Object
203 204 205 206 207 |
# File 'lib/ez_logs_agent/capturers/bulk_database_capturer.rb', line 203 def update_all(*args, **kwargs, &block) result = super ::EzLogsAgent::Capturers::BulkDatabaseCapturer.backfill_row_count(result, klass) if result.is_a?(Integer) result end |