Project

General

Profile

Bug #21993

Updated by John Mitsch over 7 years ago

When you register This is showing up in latest dev/master 

 The index call for a new smart proxy w/ content, it doesn't show up calls the search_for method from scoped_search. This results in this SQL call 

 SELECT 
    "smart_proxies"."id" AS t0_r0, 
    "smart_proxies"."NAME" AS t0_r1, 
    "smart_proxies"."url" AS t0_r2, 
    "smart_proxies"."created_at" AS t0_r3, 
    "smart_proxies"."updated_at" AS t0_r4, 
    "smart_proxies"."expired_logs" AS t0_r5, 
    "smart_proxies"."puppet_path" AS t0_r6, 
    "smart_proxies"."download_policy" AS t0_r7, 
    "taxonomies"."id" AS t1_r0, 
    "taxonomies"."NAME" AS t1_r1, 
    "taxonomies"."type" AS t1_r2, 
    "taxonomies"."created_at" AS t1_r3, 
    "taxonomies"."updated_at" AS t1_r4, 
    "taxonomies"."ignore_types" AS t1_r5, 
    "taxonomies"."description" AS t1_r6, 
    "taxonomies"."label" AS t1_r7, 
    "taxonomies"."ancestry" AS t1_r8, 
    "taxonomies"."title" AS t1_r9, 
    "organizations_smart_proxies"."id" AS t2_r0, 
    "organizations_smart_proxies"."NAME" AS t2_r1, 
    "organizations_smart_proxies"."type" AS t2_r2, 
    "organizations_smart_proxies"."created_at" AS t2_r3, 
    "organizations_smart_proxies"."updated_at" AS t2_r4, 
    "organizations_smart_proxies"."ignore_types" AS t2_r5, 
    "organizations_smart_proxies"."description" AS t2_r6, 
    "organizations_smart_proxies"."label" AS t2_r7, 
    "organizations_smart_proxies"."ancestry" AS t2_r8, 
    "organizations_smart_proxies"."title" AS t2_r9  
 FROM 
    "smart_proxies"  
    LEFT OUTER JOIN 
       "taxable_taxonomies"  
       ON "taxable_taxonomies"."taxable_id" = "smart_proxies"."id"  
       AND "taxable_taxonomies"."taxable_type" = 'SmartProxy'  
    LEFT OUTER JOIN 
       "taxonomies"  
       ON "taxonomies"."id" = "taxable_taxonomies"."taxonomy_id"  
       AND "taxonomies"."type" = 'Location'  
    LEFT OUTER JOIN 
       "taxable_taxonomies" "taxable_taxonomies_smart_proxies_join"  
       ON "taxable_taxonomies_smart_proxies_join"."taxable_id" = "smart_proxies"."id"  
       AND "taxable_taxonomies_smart_proxies_join"."taxable_type" = 'SmartProxy'  
    LEFT OUTER JOIN 
       "taxonomies" "organizations_smart_proxies"  
       ON "organizations_smart_proxies"."id" = "taxable_taxonomies_smart_proxies_join"."taxonomy_id"  
       AND "organizations_smart_proxies"."type" = 'Organization'  
 WHERE 
    ( 
       smart_proxies.id IN  
       ( 
          1 
       ) 
    ) 
 ORDER BY 
    smart_proxies.name" 




 The where clause here is limiting the UI (smart Smart proxies page) when you have an org or location selected. It would (smart_proxies.id IN 1) 

 it looks like the non-default Smart Proxies aren't loaded for the .all method for the class in scoped_search: 

 [11] pry(SmartProxy)> whereami 

 From: /home/vagrant/.rvm/gems/ruby-2.4.1/gems/scoped_search-4.1.2/lib/scoped_search/definition.rb @ line 300 SmartProxy.search_for: 

     294: @klass.define_singleton_method(:search_for) do |query = '', options = {}| 
     295:     # klass may be nice different to have @klass if the scope is called on a notification that mentions subclass 
     296:     klass = self 
     297:     definition = klass.scoped_search_definition 
     298:  
     299:     binding.pry 
  => 300:     search_scope = klass.all 
     301:     find_options = ScopedSearch::QueryBuilder.build_query(definition, query || '', options) 
     302:     search_scope = search_scope.where(find_options[:conditions])     if find_options[:conditions] 
     303:     search_scope = search_scope.includes(find_options[:include])     if find_options[:include] 
     304:     search_scope = search_scope.joins(find_options[:joins])          if find_options[:joins] 
     305:     search_scope = search_scope.reorder(find_options[:order])        if find_options[:order] 
     306:     search_scope = search_scope.references(find_options[:include]) if find_options[:include] 
     307:  
     308:     search_scope 
     309: end 

 [12] pry(SmartProxy)> klass.all 
 => [#<SmartProxy:0x00000004d63c70 
   id: 1, 
   name: "ham.john.example.com", 
   url: "https://ham.john.example.com:9090", 
   created_at: Wed, 06 Dec 2017 14:49:54 EST -05:00, 
   updated_at: Wed, 06 Dec 2017 14:49:54 EST -05:00, 
   expired_logs: "0", 
   puppet_path: "/etc/puppetlabs/code/environments", 
   download_policy: "on_demand">] 
 [13] pry(SmartProxy)> SmartProxy.all 
 => [#<SmartProxy:0x00000005180150 
   id: 1, 
   name: "ham.john.example.com", 
   url: "https://ham.john.example.com:9090", 
   created_at: Wed, 06 Dec 2017 14:49:54 EST -05:00, 
   updated_at: Wed, 06 Dec 2017 14:49:54 EST -05:00, 
   expired_logs: "0", 
   puppet_path: "/etc/puppetlabs/code/environments", 
   download_policy: "on_demand">] 
 [14] pry(SmartProxy)> klass 
 => SmartProxy(id: integer, name: string, url: string, created_at: datetime, updated_at: datetime, expired_logs: string, puppet_path: text, download_policy: string) 


 From the rails console, you have a can see there is more than one smart proxy not associated with an organization and location as that is not very intuitive. 
 irb(main):008:0> SmartProxy.all.count 
 => 2 
 irb(main):009:0> SmartProxy.all.pluck(:name) 
 => ["ham.john.example.com", "ham-proxy.john.example.com"] 



Back