Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 11:52:54 +01:00
DEV: save logs with split fields
Dieser Commit ist enthalten in:
Ursprung
aa928c319e
Commit
b79039c2e2
3 geänderte Dateien mit 16 neuen und 13 gelöschten Zeilen
|
@ -742,14 +742,11 @@ class CustomWizard::Action
|
|||
end
|
||||
|
||||
def save_log
|
||||
log = "wizard: #{@wizard.id}; action: #{action['type']}; user: #{user.username}"
|
||||
|
||||
if @log.any?
|
||||
@log.each do |item|
|
||||
log += "; #{item.to_s}"
|
||||
end
|
||||
end
|
||||
|
||||
CustomWizard::Log.create(log)
|
||||
CustomWizard::Log.create(
|
||||
@wizard.id,
|
||||
action['type'],
|
||||
user.username,
|
||||
@log.join('; ')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,22 +2,28 @@
|
|||
class CustomWizard::Log
|
||||
include ActiveModel::Serialization
|
||||
|
||||
attr_accessor :message, :date
|
||||
attr_accessor :date, :wizard, :action, :user, :message
|
||||
|
||||
PAGE_LIMIT = 100
|
||||
|
||||
def initialize(attrs)
|
||||
@message = attrs['message']
|
||||
@date = attrs['date']
|
||||
@wizard = attrs['wizard']
|
||||
@action = attrs['action']
|
||||
@user = attrs['user']
|
||||
@message = attrs['message']
|
||||
end
|
||||
|
||||
def self.create(message)
|
||||
def self.create(wizard, action, user, message)
|
||||
log_id = SecureRandom.hex(12)
|
||||
|
||||
PluginStore.set('custom_wizard_log',
|
||||
log_id.to_s,
|
||||
{
|
||||
date: Time.now,
|
||||
wizard: wizard,
|
||||
action: action,
|
||||
user: user,
|
||||
message: message
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::LogSerializer < ApplicationSerializer
|
||||
attributes :message, :date
|
||||
attributes :date, :wizard, :action, :user, :message
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren