Merge pull request #748 from warpc/735-fetch-data-for-container

[refs #735]: fill packages of BuildList when use new_core
This commit is contained in:
Vladimir Sharshov 2012-12-04 03:36:47 -08:00
commit d39c07475f
3 changed files with 77 additions and 39 deletions

View File

@ -60,8 +60,12 @@ module BuildListsHelper
end
def container_url
if @build_list.new_core?
@build_list.container_path
else
"http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe
end
end
def build_list_log_url(log_type)
"http://#{request.host_with_port}/#{@build_list.fs_log_path(log_type)}".html_safe

View File

@ -138,9 +138,6 @@
= submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish'
.hr
- if @build_list.new_core?
= render 'platforms/product_build_lists/results', :pbl => @build_list
- else
%h3= t("layout.build_lists.items_header")
- if @item_groups.blank?
%h4.nomargin= t("layout.build_lists.no_items_data")
@ -179,6 +176,10 @@
%td= package.release
.both
- if @build_list.new_core?
.hr
= render 'platforms/product_build_lists/results', :pbl => @build_list
:javascript
$('article .all').addClass('bigpadding');

View File

@ -5,19 +5,52 @@ module AbfWorker
def self.perform(options)
bl = BuildList.find options['id']
status = options['status'].to_i
item = find_or_create_item(bl)
case status
when 0
bl.build_success
item.update_attributes({:status => BuildServer::SUCCESS})
when 1
bl.build_error
item.update_attributes({:status => BuildServer::BUILD_ERROR})
when 3
bl.bs_id = bl.id
bl.save
bl.save!
bl.start_build
end
if status != 3
fill_container_data bl, options
end
end
class << self
protected
def find_or_create_item(bl)
bl.items.first || bl.items.create({
:version => bl.project_version,
:name => bl.project.name,
:status => BuildServer::BUILD_STARTED,
:level => 0
})
end
def fill_container_data(bl, options)
packages = options['packages'] || []
packages.each do |package|
package = bl.packages.build(package)
package.package_type = package['fullname'] =~ /.*\.src\.rpm$/ ? 'source' : 'binary'
package.project_id = bl.project_id
package.platform_id = bl.save_to_platform_id
package.save!
end
container = (options['results'] || []).
select{ |r| r['file_name'] !~ /.*\.log$/ }.first
sha1 = container ? container['sha1'] : nil
bl.results = options['results']
bl.save
bl.container_path = "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" if sha1
bl.save!
end
end