allow serialno pinning of jamblaster artifacts

This commit is contained in:
Seth Call 2016-12-18 22:23:05 -06:00
parent edcd297092
commit c43b6cb1b9
2 changed files with 26 additions and 7 deletions

View File

@ -30,11 +30,17 @@ ActiveAdmin.register JamRuby::SaleLineItem, :as => 'Sale Line Items' do
end
end
column 'Source' do |oo|
if oo.sale.source == JamRuby::Sale::SOURCE_PAYPAL
link_to(oo.sale.source, 'https://history.paypal.com/webscr?cmd=_history-details-from-hub&id=' + oo.sale.recurly_invoice_id)
else
oo.sale.source
end
end
column 'When' do |oo|
oo.created_at
end
column 'Link' do |oo|
end
end

View File

@ -4,23 +4,36 @@ class ArtifactsController < ApiController
# retrieve all available client downloads
def client_downloads
# jamblaster specifies this params[:type]
is_jamblaster = params[:type] && params[:serialno]
if is_jamblaster
# check and see if there is a build just for this JB
clients = ArtifactUpdate.where('product = ? and environment = ?', "JamClient/#{params[:type]}", params[:serialno]).order(:product)
if clients.count == 0
# if not, then fine, give back the default environment
clients = ArtifactUpdate.where('product = ? and environment = ?', "JamClient/#{params[:type]}", ArtifactUpdate::DEFAULT_ENVIRONMENT).order(:product)
end
else
clients = ArtifactUpdate.where("product like '%JamClient%' and environment = '#{ArtifactUpdate::DEFAULT_ENVIRONMENT}'").order(:product)
end
if params[:type]
clients = clients.where("product ilike 'JamClient/#{params[:type]}'")
if params[:serialno]
if is_jamblaster && params[:serialno]
Jamblaster.bootstrap(params[:serialno])
end
end
#Parameters: {"serialno"=>"NCA-001-160602-00084", "version"=>"dev-20161120-153542", "type"=>"jamblaster"}
#Parameters: {"serialno"=>"NCA-001-160602-00084", "version"=>"dev-20161120-153542", "type"=>"jamblasterclient"}
result = {}
clients.each do |client|
url = client.determine_url
if params[:type]
# jamblaster specifies this params[:type]
if is_jamblaster
result[params[:type]] = { :uri => url, :size => client.size, :version => client.version, :md5 => client.sha1}
else
result[client.product] = { :uri => url, :size => client.size, :version => client.version, :md5 => client.sha1}