From 405ad8fe96be853697cb2107c09dee0b5acd9473 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 19 Jun 2013 18:21:07 +0200 Subject: [PATCH] SONAR-4342, SONAR-4265 Fix batch_bootstrap/properties when working on a module --- .../controllers/batch_bootstrap_controller.rb | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb index f9088685ad7..b6ed3b66655 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/batch_bootstrap_controller.rb @@ -34,23 +34,32 @@ class BatchBootstrapController < Api::ApiController # GET /batch_bootstrap/properties?[project=] def properties - json_properties=Property.find(:all, :conditions => ['user_id is null and resource_id is null']).map { |property| to_json_property(property) } - + keys=Set.new + properties=[] + + # project properties root_project = load_project() if root_project - properties = Property.find(:all, :conditions => ["user_id is null and resource_id in (select id from projects where enabled=? and (root_id=? or id=?))", true, root_project.id, root_project.id]) - resource_ids = properties.map{|p| p.resource_id}.uniq.compact - unless resource_ids.empty? - resource_key_by_id = Project.find(:all, :select => 'id,kee', :conditions => {:id => resource_ids}).inject({}) {|hash, resource| hash[resource.id]=resource.key; hash} - properties.each do |property| - json_properties << to_json_property(property, resource_key_by_id[property.resource_id]) - end - end + # bottom-up projects + projects=[root_project].concat(root_project.ancestor_projects) + projects.each do |project| + Property.find(:all, :conditions => ['resource_id=? and user_id is null', project.id]).each do |prop| + properties< 'resource_id is null and user_id is null').each do |prop| + properties< JSON(json_properties) end -- 2.39.5