#397: added dependent_packages && dependent_projects to BuildList::Package
This commit is contained in:
parent
b06ff1f216
commit
23d3f8a0bc
|
@ -1,11 +1,14 @@
|
||||||
class BuildList::Package < ActiveRecord::Base
|
class BuildList::Package < ActiveRecord::Base
|
||||||
PACKAGE_TYPES = %w(source binary)
|
PACKAGE_TYPES = %w(source binary)
|
||||||
|
|
||||||
belongs_to :build_list
|
belongs_to :build_list, touch: true
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :platform
|
belongs_to :platform
|
||||||
|
|
||||||
attr_accessible :fullname, :name, :release, :version, :sha1, :epoch
|
serialize :dependent_packages, Array
|
||||||
|
serialize :dependent_projects, Array
|
||||||
|
|
||||||
|
attr_accessible :fullname, :name, :release, :version, :sha1, :epoch, :dependent_packages
|
||||||
|
|
||||||
validates :build_list_id, :project_id, :platform_id, :fullname,
|
validates :build_list_id, :project_id, :platform_id, :fullname,
|
||||||
:package_type, :name, :release, :version,
|
:package_type, :name, :release, :version,
|
||||||
|
@ -23,6 +26,8 @@ class BuildList::Package < ActiveRecord::Base
|
||||||
scope :like_name, ->(name) { where("#{table_name}.name ILIKE ?", "%#{name}%") if name.present? }
|
scope :like_name, ->(name) { where("#{table_name}.name ILIKE ?", "%#{name}%") if name.present? }
|
||||||
|
|
||||||
before_create :set_epoch
|
before_create :set_epoch
|
||||||
|
before_create :normalize_dependent_packages
|
||||||
|
after_commit(on: :create) { |p| p.find_dependent_projects if p.dependent_packages.present? } # later with resque
|
||||||
|
|
||||||
def assignee
|
def assignee
|
||||||
project.maintainer
|
project.maintainer
|
||||||
|
@ -45,8 +50,17 @@ class BuildList::Package < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_dependent_projects
|
||||||
|
# TODO
|
||||||
|
end
|
||||||
|
later :find_dependent_projects, queue: :middle
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def normalize_dependent_packages
|
||||||
|
self.dependent_packages = dependent_packages.split(/\s/).select(&:present?) if dependent_packages.present?
|
||||||
|
end
|
||||||
|
|
||||||
def set_epoch
|
def set_epoch
|
||||||
self.epoch = nil if epoch.blank? || epoch == 0
|
self.epoch = nil if epoch.blank? || epoch == 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,67 +1,75 @@
|
||||||
json.build_list do
|
json.build_list do
|
||||||
json.(@build_list, :id, :container_status, :status)
|
|
||||||
json.(@build_list, :update_type)
|
|
||||||
json.updated_at @build_list.updated_at
|
|
||||||
json.updated_at_utc @build_list.updated_at.strftime('%Y-%m-%d %H:%M:%S UTC')
|
|
||||||
|
|
||||||
if !@build_list.in_work? && @build_list.started_at
|
if !@build_list.in_work? && @build_list.started_at
|
||||||
json.human_duration @build_list.human_duration
|
json.human_duration @build_list.human_duration
|
||||||
elsif @build_list.in_work?
|
elsif @build_list.in_work?
|
||||||
json.human_duration "#{@build_list.human_current_duration} / #{@build_list.human_average_build_time}"
|
json.human_duration "#{@build_list.human_current_duration} / #{@build_list.human_average_build_time}"
|
||||||
end
|
end
|
||||||
|
|
||||||
json.can_publish can?(:publish, @build_list)
|
json.cache! @build_list, expires_in: 1.minute do
|
||||||
json.can_publish_into_testing can?(:publish_into_testing, @build_list) && @build_list.can_publish_into_testing?
|
json.(@build_list, :id, :container_status, :status)
|
||||||
json.can_cancel @build_list.can_cancel?
|
json.(@build_list, :update_type)
|
||||||
json.can_create_container @build_list.can_create_container?
|
json.updated_at @build_list.updated_at
|
||||||
json.can_reject_publish @build_list.can_reject_publish?
|
json.updated_at_utc @build_list.updated_at.strftime('%Y-%m-%d %H:%M:%S UTC')
|
||||||
|
|
||||||
json.extra_build_lists_published @build_list.extra_build_lists_published?
|
|
||||||
json.can_publish_in_future can_publish_in_future?(@build_list)
|
|
||||||
json.can_publish_into_repository @build_list.can_publish_into_repository?
|
|
||||||
|
|
||||||
|
|
||||||
json.container_path container_url if @build_list.container_published?
|
json.can_publish can?(:publish, @build_list)
|
||||||
|
json.can_publish_into_testing can?(:publish_into_testing, @build_list) && @build_list.can_publish_into_testing?
|
||||||
|
json.can_cancel @build_list.can_cancel?
|
||||||
|
json.can_create_container @build_list.can_create_container?
|
||||||
|
json.can_reject_publish @build_list.can_reject_publish?
|
||||||
|
|
||||||
json.publisher do
|
json.extra_build_lists_published @build_list.extra_build_lists_published?
|
||||||
json.fullname @build_list.publisher.try(:fullname)
|
json.can_publish_in_future can_publish_in_future?(@build_list)
|
||||||
json.path user_path(@build_list.publisher)
|
json.can_publish_into_repository @build_list.can_publish_into_repository?
|
||||||
end if @build_list.publisher
|
|
||||||
|
|
||||||
json.builder do
|
|
||||||
json.fullname @build_list.builder.try(:fullname)
|
|
||||||
json.path user_path(@build_list.builder)
|
|
||||||
end if @build_list.builder && (!@build_list.builder.system? || current_user.try(:admin?))
|
|
||||||
|
|
||||||
json.advisory do
|
json.container_path container_url if @build_list.container_published?
|
||||||
json.(@build_list.advisory, :description, :advisory_id)
|
|
||||||
json.path advisory_path(@build_list.advisory)
|
|
||||||
end if @build_list.advisory
|
|
||||||
|
|
||||||
json.results @build_list.results do |result|
|
json.publisher do
|
||||||
json.file_name result['file_name']
|
json.fullname @build_list.publisher.try(:fullname)
|
||||||
json.sha1 result['sha1']
|
json.path user_path(@build_list.publisher)
|
||||||
json.size result['size']
|
end if @build_list.publisher
|
||||||
|
|
||||||
timestamp = result['timestamp']
|
json.builder do
|
||||||
json.created_at Time.zone.at(result['timestamp']).to_s if timestamp
|
json.fullname @build_list.builder.try(:fullname)
|
||||||
|
json.path user_path(@build_list.builder)
|
||||||
|
end if @build_list.builder && (!@build_list.builder.system? || current_user.try(:admin?))
|
||||||
|
|
||||||
json.url file_store_results_url(result['sha1'], result['file_name'])
|
json.advisory do
|
||||||
end if @build_list.new_core? && @build_list.results.present?
|
json.(@build_list.advisory, :description, :advisory_id)
|
||||||
|
json.path advisory_path(@build_list.advisory)
|
||||||
|
end if @build_list.advisory
|
||||||
|
|
||||||
json.packages @build_list.packages do |package|
|
json.results @build_list.results do |result|
|
||||||
json.(package, :id, :name, :fullname, :release, :version, :sha1, :epoch)
|
json.file_name result['file_name']
|
||||||
json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{package.sha1}" if package.sha1
|
json.sha1 result['sha1']
|
||||||
end if @build_list.packages.present?
|
json.size result['size']
|
||||||
|
|
||||||
json.item_groups do |group|
|
timestamp = result['timestamp']
|
||||||
@item_groups.each_with_index do |group, level|
|
json.created_at Time.zone.at(result['timestamp']).to_s if timestamp
|
||||||
json.group group do |item|
|
|
||||||
json.(item, :name, :status)
|
json.url file_store_results_url(result['sha1'], result['file_name'])
|
||||||
json.path build_list_item_version_link item
|
end if @build_list.new_core? && @build_list.results.present?
|
||||||
json.level level
|
|
||||||
|
json.packages @build_list.packages do |package|
|
||||||
|
json.(package, :id, :name, :fullname, :release, :version, :sha1, :epoch)
|
||||||
|
json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{package.sha1}" if package.sha1
|
||||||
|
|
||||||
|
json.dependent_projects Project.where(id: package.dependent_projects).to_a do |project|
|
||||||
|
json.project_path project_path(project)
|
||||||
|
json.new_project_build_list_path new_project_build_list_path(@project)
|
||||||
end
|
end
|
||||||
end
|
end if @build_list.packages.present?
|
||||||
end if @item_groups.present?
|
|
||||||
|
json.item_groups do |group|
|
||||||
|
@item_groups.each_with_index do |group, level|
|
||||||
|
json.group group do |item|
|
||||||
|
json.(item, :name, :status)
|
||||||
|
json.path build_list_item_version_link item
|
||||||
|
json.level level
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end if @item_groups.present?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddDependentPackagesAndDependentProjectsToBuildListPackages < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :build_list_packages, :dependent_packages, :text
|
||||||
|
add_column :build_list_packages, :dependent_projects, :text
|
||||||
|
end
|
||||||
|
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140602164337) do
|
ActiveRecord::Schema.define(version: 20140606193047) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -90,11 +90,13 @@ ActiveRecord::Schema.define(version: 20140602164337) do
|
||||||
t.string "version"
|
t.string "version"
|
||||||
t.string "release"
|
t.string "release"
|
||||||
t.string "package_type"
|
t.string "package_type"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.boolean "actual", default: false
|
t.boolean "actual", default: false
|
||||||
t.string "sha1"
|
t.string "sha1"
|
||||||
t.integer "epoch"
|
t.integer "epoch"
|
||||||
|
t.text "dependent_packages"
|
||||||
|
t.text "dependent_projects"
|
||||||
t.index ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id"
|
t.index ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id"
|
||||||
t.index ["build_list_id"], :name => "index_build_list_packages_on_build_list_id"
|
t.index ["build_list_id"], :name => "index_build_list_packages_on_build_list_id"
|
||||||
t.index ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id"
|
t.index ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id"
|
||||||
|
|
Loading…
Reference in New Issue