meshcomplete 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/synonym.rb +2 -1
- data/lib/meshcomplete/version.rb +1 -1
- metadata +1 -1
data/app/models/synonym.rb
CHANGED
@@ -2,7 +2,8 @@ class Synonym < ActiveRecord::Base
|
|
2
2
|
belongs_to :subject
|
3
3
|
|
4
4
|
def self.search(starts_with, limit = 10)
|
5
|
-
|
5
|
+
match_keyword = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
|
6
|
+
mesh = where(["term #{match_keyword} ?", "#{starts_with}%"]).limit(limit).order("term asc").includes(:subject).group_by(&:subject)
|
6
7
|
mesh.keys.compact.sort_by(&:term).map {|m| {"id" => m.id, "label" => m.term, "value" => m.term, "entries" => mesh[m].reject {|e| m.term == e.term}.map{|e| e.term}.sort}}
|
7
8
|
end
|
8
9
|
end
|
data/lib/meshcomplete/version.rb
CHANGED