From 3e76376e97b966dc694073f4a9638c7db0b34f51 Mon Sep 17 00:00:00 2001 From: mkanoor Date: Wed, 16 Aug 2017 17:58:37 -0400 Subject: [PATCH] Removed conversion to JSON since the Hash is stored as jsonb --- .../api/automate_workspaces_controller.rb | 12 +++--------- app/controllers/api/base_controller/logger.rb | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/automate_workspaces_controller.rb b/app/controllers/api/automate_workspaces_controller.rb index e5e4e47e11..66d3b99ba5 100644 --- a/app/controllers/api/automate_workspaces_controller.rb +++ b/app/controllers/api/automate_workspaces_controller.rb @@ -9,17 +9,11 @@ def show if obj.nil? raise NotFoundError, "Invalid Workspace #{@req.c_id} specified" end - res = {} - res["id"] = obj.id - res["guid"] = obj.guid - res["input"] = JSON.parse(obj.input) - res["output"] = JSON.parse(obj.output) if obj.output - render_resource :automate_workspaces, res + render_resource :automate_workspaces, obj end def edit_resource(type, id, data = {}) - klass = collection_class(type) obj = AutomateWorkspace.find_by(:guid => id) if obj.nil? raise NotFoundError, "Invalid Workspace #{id} specified" @@ -29,8 +23,8 @@ def edit_resource(type, id, data = {}) if workspace.blank? && state_var.blank? raise BadRequestError, "No workspace or state_var specified for edit" end - current_output = obj.output ? JSON.parse(obj.output) : {} - obj.output = current_output.deep_merge(data).to_json + current_output = obj.output || {} + obj.output = current_output.deep_merge(data) obj.save obj end diff --git a/app/controllers/api/base_controller/logger.rb b/app/controllers/api/base_controller/logger.rb index 3f5990cd77..d477d10028 100644 --- a/app/controllers/api/base_controller/logger.rb +++ b/app/controllers/api/base_controller/logger.rb @@ -21,7 +21,7 @@ def log_api_auth log_request("Authentication", :type => auth_type, :token => request.headers[HttpHeaders::AUTH_TOKEN], :x_miq_group => request.headers[HttpHeaders::MIQ_GROUP], - :user => User.current_user.try(:userid)) + :user => User.current_user.userid) if User.current_user group = User.current_user.current_group log_request("Authorization", :user => User.current_user.userid,