-
-
Save mdeniz/e1e127dcdad969a2e8d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_build_flags(flag_type) | |
the_flags = {} | |
all_repositories = [nil].concat(main_object.repositories.map{|repo| repo.name}) | |
all_architecture = [nil].concat(main_object.architectures) | |
all_repositories.each do |repository| | |
the_flags[repository] = [] | |
all_architectures.each do |architecture| | |
architecture_id = architecture ? architecture.id : nil | |
flag = main_object.flags.with_repositories(repository).with_architectures(architecture_id).first | |
unless flag | |
status = (repository.nil? && architecture.nil?) ? Flag.default_state('build') : the_flags[nil].first.status | |
flag = main_object.flags.new( flag: flag_type, repo: repository, architecture: architecture, status: status ) | |
end | |
the_flags[repository] << flag | |
end | |
end | |
the_flags['all'] = the_flags.delete(nil) | |
the_flags | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment