lib/qa/authorities/mesh.rb in qa-0.0.1 vs lib/qa/authorities/mesh.rb in qa-0.0.2
- old
+ new
@@ -1,20 +1,27 @@
module Qa::Authorities
class Mesh
- def initialize(q, sub_authority=nil)
+ def results
+ @results ||= begin
+ r = Qa::SubjectMeshTerm.where('term_lower LIKE ?', "#{@q}%").limit(10)
+ r.map { |t| {id: t.term_id, label: t.term} }
+ end
+ end
+
+ def search(q, sub_authority=nil)
@q = q
end
- def results
+ def get_full_record(id)
@results ||= begin
- r = SubjectMeshTerm.where('term_lower LIKE ?', "#{@q}%").limit(10)
- r.map { |t| {id: t.term_id, label: t.term} }
- end.to_json
+ r = Qa::SubjectMeshTerm.where(term_id: id).limit(1).first
+ r.nil? ? nil : {id: r.term_id, label: r.term, synonyms: r.synonyms}
+ end
end
# satisfy TermsController
def parse_authority_response
end
end
-end
\ No newline at end of file
+end