Merge branch 'master' into 286-add-sorting-by-status-inside-groups-at-monitoring-page

This commit is contained in:
Vokhmin Alexey V 2013-08-30 17:47:46 +04:00
commit c4b31f0cf6
6 changed files with 14 additions and 4 deletions

View File

@ -45,7 +45,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 {

View File

@ -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

View File

@ -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)

View File

@ -1,6 +1,6 @@
now = Time.now.utc
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

View File

@ -0,0 +1,5 @@
class AddGroupIdToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :group_id, :integer
end
end

View File

@ -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"