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