Commit eee6f248519c6f8a5e81532dc88fb3b020c86ca0

Authored by Fabio Teixeira
Committed by Luciano Prestes
1 parent ddfbf3f3

fixes_software: Reduces the effort of queries for DatabaseDescription in the bank

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
controllers/mpog_software_plugin_controller.rb
@@ -151,10 +151,10 @@ class MpogSoftwarePluginController &lt; ApplicationController @@ -151,10 +151,10 @@ class MpogSoftwarePluginController &lt; ApplicationController
151 def get_databases 151 def get_databases
152 return render :json=>{} unless request.xhr? and params[:query] 152 return render :json=>{} unless request.xhr? and params[:query]
153 153
154 - data = DatabaseDescription.where("name ILIKE ?", "%#{params[:query]}%").collect {|db| 154 + data = DatabaseDescription.where("name ILIKE ?", "%#{params[:query]}%").select("id, name").collect {|db|
155 {:id=>db.id, :label=>db.name} 155 {:id=>db.id, :label=>db.name}
156 } 156 }
157 - other = [DatabaseDescription.last].collect { |db| 157 + other = [DatabaseDescription.select("id, name").last].collect { |db|
158 {:id=>db.id, :label=>db.name} 158 {:id=>db.id, :label=>db.name}
159 } 159 }
160 160
lib/database_helper.rb
@@ -51,7 +51,7 @@ module DatabaseHelper @@ -51,7 +51,7 @@ module DatabaseHelper
51 database_name = if database_data[:database_description_id].blank? 51 database_name = if database_data[:database_description_id].blank?
52 "" 52 ""
53 else 53 else
54 - DatabaseDescription.find(database_data[:database_description_id]).name 54 + DatabaseDescription.find(database_data[:database_description_id], :select=>"name").name
55 end 55 end
56 56
57 Proc::new do 57 Proc::new do