Merge pull request #290 from abf/rosa-build:289-global-id-for-group-of-build-lists
#289: Global ID for group of build_lists
This commit is contained in:
commit
5939bde21d
|
@ -30,7 +30,8 @@ RosaABF.controller('BuildListsController', ['$scope', '$http', '$location', '$ti
|
|||
// Grouping of build_lists
|
||||
_.each(results.build_lists, function(r){
|
||||
var bl = new BuildList(r, dictionary);
|
||||
var key = bl.project_id + '-' + bl.commit_hash + '-' + bl.user_id;
|
||||
var key = bl.project_id + '-';
|
||||
key += bl.group_id ? bl.group_id : (bl.commit_hash + '-' + bl.user_id);
|
||||
if (groups[key]) {
|
||||
groups[key].addRelated(bl);
|
||||
} else {
|
||||
|
|
|
@ -62,6 +62,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
build_for_platforms = Repository.select(:platform_id).
|
||||
where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
|
||||
|
||||
build_lists = []
|
||||
Arch.where(:id => params[:arches]).each do |arch|
|
||||
Platform.main.where(:id => build_for_platforms).each do |build_for_platform|
|
||||
@build_list = @project.build_lists.build(params[:build_list])
|
||||
|
@ -71,6 +72,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name}
|
||||
if authorize!(:create, @build_list) && @build_list.save
|
||||
build_lists << @build_list
|
||||
notices << t("flash.build_list.saved", flash_options)
|
||||
else
|
||||
errors << t("flash.build_list.save_error", flash_options)
|
||||
|
@ -83,6 +85,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
flash[:error] = errors.join('<br>').html_safe
|
||||
render :action => :new
|
||||
else
|
||||
BuildList.where(:id => build_lists.map(&:id)).update_all(:group_id => build_lists[0].id) if build_lists.size > 1
|
||||
flash[:notice] = notices.join('<br>').html_safe
|
||||
redirect_to project_build_lists_path(@project)
|
||||
end
|
||||
|
|
|
@ -299,7 +299,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def average_build_time
|
||||
project.project_statistics.where(:arch_id => arch_id).first.try(:average_build_time) || 0
|
||||
project.project_statistics.where(:arch_id => arch_id).pluck(:average_build_time).first || 0
|
||||
end
|
||||
|
||||
def self.human_status(status)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
now = Time.now.utc
|
||||
users, projects, platforms, repositories = [], [], [], []
|
||||
json.build_lists @build_lists do |build_list|
|
||||
json.(build_list, :id, :status, :project_id, :project_version, :save_to_platform_id, :save_to_repository_id, :user_id, :project_id, :build_for_platform_id, :arch_id)
|
||||
json.(build_list, :id, :status, :project_id, :project_version, :save_to_platform_id, :save_to_repository_id, :user_id, :project_id, :build_for_platform_id, :arch_id, :group_id)
|
||||
json.commit_hash build_list.commit_hash.first(5)
|
||||
json.last_published_commit_hash build_list.last_published_commit_hash.first(5) if build_list.last_published_commit_hash
|
||||
|
||||
|
@ -11,21 +12,26 @@ json.build_lists @build_lists do |build_list|
|
|||
|
||||
json.version_release get_version_release(build_list)
|
||||
json.updated_at build_list.updated_at.strftime('%d/%m/%Y')
|
||||
|
||||
users |= [build_list.user]
|
||||
projects |= [build_list.project]
|
||||
platforms |= [build_list.build_for_platform, build_list.save_to_platform]
|
||||
repositories |= [build_list.save_to_repository]
|
||||
end
|
||||
|
||||
json.dictionary do
|
||||
json.users @build_lists.map(&:user).uniq do |user|
|
||||
json.users users.compact do |user|
|
||||
json.(user, :id, :uname, :fullname)
|
||||
end
|
||||
json.projects @build_lists.map(&:project).uniq.compact do |project|
|
||||
json.projects projects.compact do |project|
|
||||
json.(project, :id, :name)
|
||||
json.owner project.name_with_owner.gsub(/\/.*/, '')
|
||||
end
|
||||
json.platforms (@build_lists.map(&:build_for_platform) | @build_lists.map(&:save_to_platform)).uniq do |platform|
|
||||
json.platforms platforms.compact do |platform|
|
||||
json.(platform, :id, :name)
|
||||
json.personal platform.personal?
|
||||
end
|
||||
json.repositories @build_lists.map(&:save_to_repository).uniq do |repository|
|
||||
json.repositories repositories.compact do |repository|
|
||||
json.(repository, :id, :name)
|
||||
end
|
||||
json.arches Arch.all do |arch|
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddGroupIdToBuildList < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :build_lists, :group_id, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130827144022) do
|
||||
ActiveRecord::Schema.define(:version => 20130829161042) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -136,6 +136,7 @@ ActiveRecord::Schema.define(:version => 20130827144022) do
|
|||
t.text "extra_repositories"
|
||||
t.text "extra_build_lists"
|
||||
t.integer "publisher_id"
|
||||
t.integer "group_id"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"
|
||||
|
|
Loading…
Reference in New Issue