DEV: specify which fields to split in log data migration
Dieser Commit ist enthalten in:
Ursprung
b79039c2e2
Commit
35ff172967
1 geänderte Dateien mit 13 neuen und 6 gelöschten Zeilen
|
@ -16,16 +16,23 @@ class SplitCustomWizardLogFields < ActiveRecord::Migration[6.1]
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
# first three keys are wizard/action/user
|
|
||||||
|
|
||||||
if log_json.key?('message')
|
if log_json.key?('message') and log_json['message'].is_a? String
|
||||||
attr_strs = log_json['message'].split('; ', 4)
|
|
||||||
|
|
||||||
log_json['message'] = attr_strs.pop
|
attr_strs = []
|
||||||
|
|
||||||
|
# assumes no whitespace in the values
|
||||||
|
attr_strs << log_json['message'].slice!(/(wizard: \S*; )/, 1)
|
||||||
|
attr_strs << log_json['message'].slice!(/(action: \S*; )/, 1)
|
||||||
|
attr_strs << log_json['message'].slice!(/(user: \S*; )/, 1)
|
||||||
|
|
||||||
attr_strs.each do |attr_str|
|
attr_strs.each do |attr_str|
|
||||||
|
if attr_str.is_a? String
|
||||||
|
attr_str.gsub!(/[;]/ ,"")
|
||||||
key, value = attr_str.split(': ')
|
key, value = attr_str.split(': ')
|
||||||
log_json[key] = value
|
value.strip! if value
|
||||||
|
log_json[key] = value ? value : ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
row.value = log_json.to_json
|
row.value = log_json.to_json
|
||||||
|
|
Laden …
In neuem Issue referenzieren