do not save username since we are already saving user_id
This commit is contained in:
parent
83b1fcb54b
commit
d9e7b438b4
12
plugin.rb
12
plugin.rb
|
@ -567,7 +567,7 @@ SQL
|
|||
|
||||
# Reimplement a couple ActiveRecord methods, but use PluginStore for storage instead
|
||||
class DataExplorer::Query
|
||||
attr_accessor :id, :name, :description, :sql, :created_by, :created_at, :username
|
||||
attr_accessor :id, :name, :description, :sql, :created_by, :created_at
|
||||
|
||||
def initialize
|
||||
@name = 'Unnamed Query'
|
||||
|
@ -609,7 +609,7 @@ SQL
|
|||
|
||||
def self.from_hash(h)
|
||||
query = DataExplorer::Query.new
|
||||
[:name, :description, :sql, :created_by, :created_at, :username].each do |sym|
|
||||
[:name, :description, :sql, :created_by, :created_at].each do |sym|
|
||||
query.send("#{sym}=", h[sym].strip) if h[sym]
|
||||
end
|
||||
query.id = h[:id].to_i if h[:id]
|
||||
|
@ -623,8 +623,7 @@ SQL
|
|||
description: @description,
|
||||
sql: @sql,
|
||||
created_by: @created_by,
|
||||
created_at: @created_at,
|
||||
username: @username
|
||||
created_at: @created_at
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -943,7 +942,6 @@ SQL
|
|||
query = DataExplorer::Query.from_hash params.require(:query)
|
||||
query.created_at = Time.now.strftime("%b %e, %Y")
|
||||
query.created_by = current_user.id.to_s
|
||||
query.username = User.find(query.created_by).username
|
||||
query.id = nil # json import will assign an id, which is wrong
|
||||
query.save
|
||||
|
||||
|
@ -1084,6 +1082,10 @@ SQL
|
|||
def param_info
|
||||
object.params.map(&:to_hash) rescue nil
|
||||
end
|
||||
|
||||
def username
|
||||
User.find(created_by).username rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
DataExplorer::Engine.routes.draw do
|
||||
|
|
Loading…
Reference in New Issue