diff --git a/app/assets/javascripts/angularjs/controllers/build_lists_controller.js b/app/assets/javascripts/angularjs/controllers/build_lists_controller.js
index 20834986a..9e873c589 100644
--- a/app/assets/javascripts/angularjs/controllers/build_lists_controller.js
+++ b/app/assets/javascripts/angularjs/controllers/build_lists_controller.js
@@ -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 {
diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb
index dd6394412..e6f39d222 100644
--- a/app/controllers/projects/build_lists_controller.rb
+++ b/app/controllers/projects/build_lists_controller.rb
@@ -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('
').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('
').html_safe
redirect_to project_build_lists_path(@project)
end
diff --git a/app/models/build_list.rb b/app/models/build_list.rb
index 7ddb2a00c..0f8b8cade 100644
--- a/app/models/build_list.rb
+++ b/app/models/build_list.rb
@@ -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)
diff --git a/app/views/projects/build_lists/index.json.jbuilder b/app/views/projects/build_lists/index.json.jbuilder
index 47fa83883..73f74b7e8 100644
--- a/app/views/projects/build_lists/index.json.jbuilder
+++ b/app/views/projects/build_lists/index.json.jbuilder
@@ -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|
diff --git a/db/migrate/20130829161042_add_group_id_to_build_list.rb b/db/migrate/20130829161042_add_group_id_to_build_list.rb
new file mode 100644
index 000000000..6662f14b0
--- /dev/null
+++ b/db/migrate/20130829161042_add_group_id_to_build_list.rb
@@ -0,0 +1,5 @@
+class AddGroupIdToBuildList < ActiveRecord::Migration
+ def change
+ add_column :build_lists, :group_id, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e64fc12d4..2e0a0ed69 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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"