#354: autostart build_lists for personal platforms
This commit is contained in:
parent
0951ef6609
commit
21ac1aef1c
|
@ -15,9 +15,7 @@ module BuildListsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def availables_main_platforms
|
def availables_main_platforms
|
||||||
# Main platforms with repositories
|
Platform.availables_main_platforms current_user, current_ability
|
||||||
Platform.main.accessible_by(current_ability, :show)
|
|
||||||
.includes(:repositories).where('repositories.id IS NOT NULL').order('platforms.name').uniq
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_to_repositories(project)
|
def save_to_repositories(project)
|
||||||
|
|
|
@ -243,6 +243,15 @@ class Platform < ActiveRecord::Base
|
||||||
Platform.main.where(automatic_metadata_regeneration: value).each(&:regenerate)
|
Platform.main.where(automatic_metadata_regeneration: value).each(&:regenerate)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.availables_main_platforms(user, ability = nil)
|
||||||
|
p_ids = Rails.cache.fetch([:availables_main_platforms, user], expires_in: 10.minutes) do
|
||||||
|
ability ||= Ability.new user
|
||||||
|
Platform.main.accessible_by(ability, :show).joins(:repositories).
|
||||||
|
where('repositories.id IS NOT NULL').pluck(:id)
|
||||||
|
end
|
||||||
|
Platform.preload(:repositories).where(id: p_ids).order(:name)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def create_directory
|
def create_directory
|
||||||
|
|
|
@ -309,20 +309,27 @@ class Project < ActiveRecord::Base
|
||||||
Project.where(autostart_status: autostart_status).find_each do |p|
|
Project.where(autostart_status: autostart_status).find_each do |p|
|
||||||
p.project_to_repositories.autostart_enabled.includes(repository: :platform).each do |p_to_r|
|
p.project_to_repositories.autostart_enabled.includes(repository: :platform).each do |p_to_r|
|
||||||
repository = p_to_r.repository
|
repository = p_to_r.repository
|
||||||
platform = repository.platform
|
user = User.find(p_to_r.user_id)
|
||||||
platform.platform_arch_settings.by_default.pluck(:arch_id).each do |arch_id|
|
if repository.platform.personal?
|
||||||
build_list = p.build_lists.build do |bl|
|
platforms = Platform.availables_main_platforms(user)
|
||||||
bl.save_to_platform = platform
|
else
|
||||||
bl.build_for_platform = platform
|
platforms = [repository.platform]
|
||||||
bl.update_type = 'newpackage'
|
end
|
||||||
bl.arch_id = arch_id
|
platforms.each do |platform|
|
||||||
bl.project_version = p.project_version_for(platform, platform)
|
platform.platform_arch_settings.by_default.pluck(:arch_id).each do |arch_id|
|
||||||
bl.user = User.find(p_to_r.user_id)
|
build_list = p.build_lists.build do |bl|
|
||||||
bl.auto_publish = p_to_r.auto_publish == 'true'
|
bl.save_to_platform = repository.platform
|
||||||
bl.save_to_repository = repository
|
bl.build_for_platform = platform
|
||||||
bl.include_repos = [repository.id, platform.repositories.main.first.try(:id)].uniq.compact
|
bl.update_type = 'newpackage'
|
||||||
|
bl.arch_id = arch_id
|
||||||
|
bl.project_version = p.project_version_for(platform, platform)
|
||||||
|
bl.user = user
|
||||||
|
bl.auto_publish = p_to_r.auto_publish == 'true'
|
||||||
|
bl.save_to_repository = repository
|
||||||
|
bl.include_repos = [repository.id, platform.repositories.main.first.try(:id)].uniq.compact
|
||||||
|
end
|
||||||
|
build_list.save!
|
||||||
end
|
end
|
||||||
build_list.save!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class Relation < ActiveRecord::Base
|
class Relation < ActiveRecord::Base
|
||||||
belongs_to :target, polymorphic: true
|
belongs_to :target, polymorphic: true
|
||||||
belongs_to :actor, polymorphic: true
|
belongs_to :actor, polymorphic: true, touch: true
|
||||||
|
|
||||||
ROLES = %w[reader writer admin]
|
ROLES = %w[reader writer admin]
|
||||||
validates :role, inclusion: {in: ROLES}
|
validates :role, inclusion: {in: ROLES}
|
||||||
|
|
Loading…
Reference in New Issue