2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-04-11 11:47:57 +01:00
|
|
|
class BuildList::Item < ActiveRecord::Base
|
2012-01-23 18:11:53 +00:00
|
|
|
|
2011-04-11 11:47:57 +01:00
|
|
|
belongs_to :build_list
|
|
|
|
|
|
|
|
attr_protected :build_list_id
|
|
|
|
|
2012-01-23 18:11:53 +00:00
|
|
|
GIT_ERROR = 5
|
|
|
|
|
|
|
|
STATUSES = [BuildServer::SUCCESS, BuildServer::DEPENDENCIES_ERROR, BuildServer::BUILD_ERROR, BuildServer::BUILD_STARTED, GIT_ERROR]
|
2011-04-11 11:47:57 +01:00
|
|
|
HUMAN_STATUSES = {
|
2011-04-22 17:13:47 +01:00
|
|
|
nil => :unknown,
|
2012-01-23 18:11:53 +00:00
|
|
|
GIT_ERROR => :git_error,
|
2011-12-12 12:34:20 +00:00
|
|
|
BuildServer::DEPENDENCIES_ERROR => :dependencies_error,
|
2011-10-29 18:50:47 +01:00
|
|
|
BuildServer::SUCCESS => :success,
|
2011-12-12 12:34:20 +00:00
|
|
|
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
|