Skip to content

Commit 61cc2b9

Browse files
floehopperchrislo
authored andcommitted
Log ImmunisationImport events
Co-authored-by: James Mead <james.mead@gofreerange.com>
1 parent 9fdeea5 commit 61cc2b9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

app/models/immunisation_import.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class ImmunisationImport < ApplicationRecord
4444
has_and_belongs_to_many :sessions
4545
has_and_belongs_to_many :vaccination_records
4646

47+
after_create :log_started
48+
4749
def type_label
4850
"Vaccination records"
4951
end
@@ -89,6 +91,7 @@ def process!
8991
post_commit!
9092

9193
update_columns(processed_at: Time.zone.now, status: :processed, **counts)
94+
log_finished
9295
end
9396

9497
private
@@ -224,4 +227,18 @@ def post_commit!
224227

225228
TeamCachedCounts.new(team).reset_import_issues!
226229
end
230+
231+
def log_started
232+
with_logger_tags { logger.info("started", started_at: created_at) }
233+
end
234+
235+
def log_finished
236+
with_logger_tags do
237+
logger.info("finished", finished_at: processed_at, row_count: rows.count)
238+
end
239+
end
240+
241+
def with_logger_tags(&)
242+
SemanticLogger.tagged(import_class: model_name.to_s, import_id: id, &)
243+
end
227244
end

0 commit comments

Comments
 (0)