0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 02:30:28 +01:00

DEV: specify which fields to split in log data migration

Dieser Commit ist enthalten in:
KC Maddever 2021-08-24 20:41:51 +08:00
Ursprung b79039c2e2
Commit 35ff172967

Datei anzeigen

@ -16,16 +16,23 @@ class SplitCustomWizardLogFields < ActiveRecord::Migration[6.1]
next
end
# first three keys are wizard/action/user
if log_json.key?('message')
attr_strs = log_json['message'].split('; ', 4)
if log_json.key?('message') and log_json['message'].is_a? String
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|
key, value = attr_str.split(': ')
log_json[key] = value
if attr_str.is_a? String
attr_str.gsub!(/[;]/ ,"")
key, value = attr_str.split(': ')
value.strip! if value
log_json[key] = value ? value : ''
end
end
row.value = log_json.to_json