Commit eee6f248519c6f8a5e81532dc88fb3b020c86ca0
Committed by
Luciano Prestes
1 parent
ddfbf3f3
Exists in
master
and in
5 other branches
fixes_software: Reduces the effort of queries for DatabaseDescription in the bank
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
controllers/mpog_software_plugin_controller.rb
@@ -151,10 +151,10 @@ class MpogSoftwarePluginController < ApplicationController | @@ -151,10 +151,10 @@ class MpogSoftwarePluginController < 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 |