[ARVADOS] updated: 84f0a30a119355cd7deff1630a82d3d4c9a6d5ee
git at public.curoverse.com
git at public.curoverse.com
Wed Jan 15 00:42:33 EST 2014
Summary of changes:
.../app/controllers/collections_controller.rb | 6 ++++--
.../api/app/controllers/application_controller.rb | 10 ++++++++--
services/api/app/models/arvados_model.rb | 8 ++++++++
3 files changed, 20 insertions(+), 4 deletions(-)
via 84f0a30a119355cd7deff1630a82d3d4c9a6d5ee (commit)
from 5225a4deab9bf526d4e178cb5220f790b3d33e67 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 84f0a30a119355cd7deff1630a82d3d4c9a6d5ee
Author: Tom Clegg <tom at curoverse.com>
Date: Tue Jan 14 21:13:32 2014 -0800
With where={"any":["contains",X]}, search all text and string columns.
closes #1867
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index fe861eb..447b34d 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -8,8 +8,10 @@ class CollectionsController < ApplicationController
def index
if params[:search].andand.length.andand > 0
- tags = Link.where(link_class: 'tag', any: ['contains', params[:search]])
- @collections = Collection.where(uuid: tags.collect(&:head_uuid))
+ tags = Link.where(any: ['contains', params[:search]])
+ @collections = (Collection.where(uuid: tags.collect(&:head_uuid)) |
+ Collection.where(any: ['contains', params[:search]])).
+ uniq { |c| c.uuid }
else
@collections = Collection.limit(100)
end
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 708defe..2b7b34b 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -129,8 +129,14 @@ class ApplicationController < ActionController::Base
if value.is_a?(Array) and
value[0] == 'contains' and
model_class.columns.collect(&:name).index('name') then
- conditions[0] << " and #{table_name}.name ilike ?"
- conditions << "%#{value[1]}%"
+ ilikes = []
+ model_class.searchable_columns.each do |column|
+ ilikes << "#{table_name}.#{column} ilike ?"
+ conditions << "%#{value[1]}%"
+ end
+ if ilikes.any?
+ conditions[0] << ' and (' + ilikes.join(' or ') + ')'
+ end
end
elsif attr.to_s.match(/^[a-z][_a-z0-9]+$/) and
model_class.columns.collect(&:name).index(attr.to_s)
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 991755b..2999b52 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -36,6 +36,14 @@ class ArvadosModel < ActiveRecord::Base
"#{current_api_base}/#{self.class.to_s.pluralize.underscore}/#{self.uuid}"
end
+ def self.searchable_columns
+ self.columns.collect do |col|
+ if [:string, :text].index(col.type) && col.name != 'owner_uuid'
+ col.name
+ end
+ end.compact
+ end
+
def eager_load_associations
self.class.columns.each do |col|
re = col.name.match /^(.*)_kind$/
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list