jam-cloud/admin/app/controllers/artifacts_controller.rb

37 lines
941 B
Ruby

class ArtifactsController < ApplicationController
respond_to :json
# create or update a client_artifact row
def update_artifacts
product = params[:product]
version = params[:version]
uri = params[:uri]
file = params[:file]
environment = params[:environment]
ArtifactUpdate.transaction do
# VRFS-1071: Postpone client update notification until installer is available for download
ArtifactUpdate.connection.execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED')
@artifact = ArtifactUpdate.find_or_create_by({product: product, environement: environment})
@artifact.version = version
@artifact.uri = file
@artifact.save
if @artifact.save
@artifact.send_notice
end
end
unless @artifact.errors.any?
render :json => {}, :status => :ok
else
response.status = :unprocessable_entity
respond_with @artifact
end
end
end