show file size, and in_queue status for ProductBuildList

This commit is contained in:
Vokhmin Alexey V 2012-11-19 19:11:07 +04:00
parent ec68d070f7
commit ebbf47f818
5 changed files with 29 additions and 10 deletions

View File

@ -3,18 +3,24 @@ class ProductBuildList < ActiveRecord::Base
include Modules::Models::CommitAndVersion include Modules::Models::CommitAndVersion
delegate :url_helpers, to: 'Rails.application.routes' delegate :url_helpers, to: 'Rails.application.routes'
BUILD_STARTED = 2
BUILD_COMPLETED = 0 BUILD_COMPLETED = 0
BUILD_FAILED = 1 BUILD_FAILED = 1
BUILD_IN_QUEUE = 2
BUILD_STARTED = 3
BUILD_CANCELED = 4
STATUSES = [ BUILD_STARTED, STATUSES = [ BUILD_STARTED,
BUILD_COMPLETED, BUILD_COMPLETED,
BUILD_FAILED BUILD_FAILED,
BUILD_IN_QUEUE,
BUILD_CANCELED
] ]
HUMAN_STATUSES = { BUILD_STARTED => :build_started, HUMAN_STATUSES = { BUILD_STARTED => :build_started,
BUILD_COMPLETED => :build_completed, BUILD_COMPLETED => :build_completed,
BUILD_FAILED => :build_failed BUILD_FAILED => :build_failed,
BUILD_IN_QUEUE => :in_queue,
BUILD_CANCELED => :build_canceled
} }
belongs_to :product belongs_to :product
@ -28,7 +34,7 @@ class ProductBuildList < ActiveRecord::Base
:main_script, :main_script,
:time_living, :time_living,
:arch_id, :presence => true :arch_id, :presence => true
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] } validates :status, :inclusion => { :in => STATUSES }
attr_accessor :base_url attr_accessor :base_url
attr_accessible :status, attr_accessible :status,
@ -84,6 +90,7 @@ class ProductBuildList < ActiveRecord::Base
end end
def stop def stop
update_attributes({:status => BUILD_CANCELED})
Resque.redis.setex( Resque.redis.setex(
"abfworker::iso-worker-#{id}::live-inspector", "abfworker::iso-worker-#{id}::live-inspector",
120, # Data will be removed from Redis after 120 sec. 120, # Data will be removed from Redis after 120 sec.
@ -105,8 +112,8 @@ class ProductBuildList < ActiveRecord::Base
options = { options = {
:id => id, :id => id,
# TODO: remove comment # TODO: remove comment
# :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz',
:srcpath => srcpath, # :srcpath => srcpath,
:params => params, :params => params,
:time_living => time_living, :time_living => time_living,
:main_script => main_script, :main_script => main_script,

View File

@ -39,12 +39,14 @@
%tr %tr
%th= t("activerecord.attributes.product_build_list/results.file_name") %th= t("activerecord.attributes.product_build_list/results.file_name")
%th= t("activerecord.attributes.product_build_list/results.sha1") %th= t("activerecord.attributes.product_build_list/results.sha1")
%th= t("activerecord.attributes.product_build_list/results.size")
%tbody %tbody
- pbl.results.each do |item| - pbl.results.each do |item|
%tr %tr
- sha1 = item['sha1'] - sha1 = item['sha1']
%td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" %td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
%td= sha1 %td= sha1
%td= item['size']
.both .both

View File

@ -17,10 +17,14 @@ en:
statuses: statuses:
'0': 'build' '0': 'build'
'1': 'build error' '1': 'build error'
'2': 'build in progress' '2': 'in queue'
'3': 'build in progress'
'4': 'build canceled'
build_failed: Build failed build_failed: Build failed
build_started: Build in progress build_started: Build in progress
build_completed: Built build_completed: Built
build_canceled: Build canceled
in_queue: In queue
ownership: ownership:
header: Build list ownership header: Build list ownership
@ -46,6 +50,7 @@ en:
product_build_list/results: product_build_list/results:
file_name: File name file_name: File name
sha1: SHA1 sha1: SHA1
size: Size (MB)
flash: flash:
product_build_list: product_build_list:

View File

@ -17,10 +17,14 @@ ru:
statuses: statuses:
'0': 'собран' '0': 'собран'
'1': 'ошибка сборки' '1': 'ошибка сборки'
'2': 'собирается' '2': 'в очереди'
'3': 'собирается'
'4': 'отменен'
build_failed: Ошибка сборки build_failed: Ошибка сборки
build_started: Собирается build_started: Собирается
build_completed: Собран build_completed: Собран
build_canceled: Отменен
in_queue: В очереди
ownership: ownership:
header: Принадлежность заданий header: Принадлежность заданий
@ -46,6 +50,7 @@ ru:
product_build_list/results: product_build_list/results:
file_name: Имя файла file_name: Имя файла
sha1: SHA1 sha1: SHA1
size: Размер (МБ)
flash: flash:
product_build_list: product_build_list:

View File

@ -5,7 +5,7 @@ module AbfWorker
def self.perform(options) def self.perform(options)
status = options['status'].to_i status = options['status'].to_i
pbl = ProductBuildList.find options['id'] pbl = ProductBuildList.find options['id']
pbl.status = status pbl.status = status if pbl.status != ProductBuildList::BUILD_CANCELED
pbl.results = options['results'] if status != ProductBuildList::BUILD_STARTED pbl.results = options['results'] if status != ProductBuildList::BUILD_STARTED
pbl.save! pbl.save!
end end