#289: added global_id into build_list

This commit is contained in:
Vokhmin Alexey V 2013-08-29 21:46:11 +04:00
parent 9cc58d5468
commit afc136db9c
6 changed files with 23 additions and 8 deletions

View File

@ -30,7 +30,7 @@ RosaABF.controller('BuildListsController', ['$scope', '$http', '$location', '$ti
// Grouping of build_lists // Grouping of build_lists
_.each(results.build_lists, function(r){ _.each(results.build_lists, function(r){
var bl = new BuildList(r, dictionary); var bl = new BuildList(r, dictionary);
var key = bl.project_id + '-' + bl.commit_hash + '-' + bl.user_id; var key = bl.project_id + '-' + bl.group_id;
if (groups[key]) { if (groups[key]) {
groups[key].addRelated(bl); groups[key].addRelated(bl);
} else { } else {

View File

@ -62,6 +62,7 @@ class Projects::BuildListsController < Projects::BaseController
build_for_platforms = Repository.select(:platform_id). build_for_platforms = Repository.select(:platform_id).
where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&: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| Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => build_for_platforms).each do |build_for_platform| Platform.main.where(:id => build_for_platforms).each do |build_for_platform|
@build_list = @project.build_lists.build(params[:build_list]) @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} 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 if authorize!(:create, @build_list) && @build_list.save
build_lists << @build_list
notices << t("flash.build_list.saved", flash_options) notices << t("flash.build_list.saved", flash_options)
else else
errors << t("flash.build_list.save_error", flash_options) 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 flash[:error] = errors.join('<br>').html_safe
render :action => :new render :action => :new
else 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 flash[:notice] = notices.join('<br>').html_safe
redirect_to project_build_lists_path(@project) redirect_to project_build_lists_path(@project)
end end

View File

@ -299,7 +299,7 @@ class BuildList < ActiveRecord::Base
end end
def average_build_time 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 end
def self.human_status(status) def self.human_status(status)

View File

@ -1,6 +1,7 @@
now = Time.now.utc now = Time.now.utc
users, projects, platforms, repositories = [], [], [], []
json.build_lists @build_lists do |build_list| 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.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 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.version_release get_version_release(build_list)
json.updated_at build_list.updated_at.strftime('%d/%m/%Y') 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 end
json.dictionary do json.dictionary do
json.users @build_lists.map(&:user).uniq do |user| json.users users.compact do |user|
json.(user, :id, :uname, :fullname) json.(user, :id, :uname, :fullname)
end end
json.projects @build_lists.map(&:project).uniq.compact do |project| json.projects projects.compact do |project|
json.(project, :id, :name) json.(project, :id, :name)
json.owner project.name_with_owner.gsub(/\/.*/, '') json.owner project.name_with_owner.gsub(/\/.*/, '')
end 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.(platform, :id, :name)
json.personal platform.personal? json.personal platform.personal?
end end
json.repositories @build_lists.map(&:save_to_repository).uniq do |repository| json.repositories repositories.compact do |repository|
json.(repository, :id, :name) json.(repository, :id, :name)
end end
json.arches Arch.all do |arch| json.arches Arch.all do |arch|

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. # 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| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -136,6 +136,7 @@ ActiveRecord::Schema.define(:version => 20130827144022) do
t.text "extra_repositories" t.text "extra_repositories"
t.text "extra_build_lists" t.text "extra_build_lists"
t.integer "publisher_id" t.integer "publisher_id"
t.integer "group_id"
end end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"