rosa-build/app/models/build_list/item.rb

40 lines
1.0 KiB
Ruby
Raw Normal View History

2011-04-11 11:47:57 +01:00
class BuildList::Item < ActiveRecord::Base
belongs_to :build_list
attr_protected :build_list_id
STATUSES = [BuildServer::SUCCESS, BuildServer::DEPENDENCIES_ERROR, BuildServer::BUILD_ERROR, BuildServer::BUILD_STARTED]
2011-04-11 11:47:57 +01:00
HUMAN_STATUSES = {
2011-04-22 17:13:47 +01:00
nil => :unknown,
BuildServer::DEPENDENCIES_ERROR => :dependencies_error,
2011-10-29 18:50:47 +01:00
BuildServer::SUCCESS => :success,
BuildServer::BUILD_STARTED => :build_started,
2011-10-29 18:50:47 +01:00
BuildServer::BUILD_ERROR => :build_error
2011-04-11 11:47:57 +01:00
}
scope :recent, order("level ASC, name ASC")
def self.group_by_level
items = scoped({}).recent
groups = []
current_level = -1
items.each do |item|
groups << [] if current_level < item.level
groups.last << item
current_level = item.level
end
groups
end
def self.human_status(status)
I18n.t("layout.build_lists.items.statuses.#{HUMAN_STATUSES[status]}")
end
def human_status
self.class.human_status(status)
end
2011-04-22 17:13:47 +01:00
end