10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/models/solid_events/journey.rb', line 10
def materialize_from_summary!(summary)
key = journey_key_for(summary)
return if key.blank?
journey = find_or_initialize_by(journey_key: key)
journey.request_id = summary.request_id if summary.request_id.present?
journey.entity_type = summary.entity_type if summary.entity_type.present?
journey.entity_id = summary.entity_id if summary.entity_id.present?
journey.last_trace_id = summary.trace_id
journey.started_at = [journey.started_at, summary.started_at].compact.min || summary.started_at
journey.finished_at = [journey.finished_at, summary.finished_at || summary.started_at].compact.max || summary.started_at
journey.trace_count = summary_count_for(key)
journey.error_count = summary_error_count_for(key)
journey.payload = {
source: summary.source,
name: summary.name
}
journey.save!
journey
rescue StandardError
nil
end
|