Skip to content

Commit

Permalink
Limit drug name suggestions
Browse files Browse the repository at this point in the history
Only return local name suggestions in the typeahead for drugs already
associated with an accepted evidence item.
  • Loading branch information
acoffman committed Aug 29, 2019
1 parent 39fc579 commit a1a8a03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/drug_name_suggestion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ def self.get_pubchem_suggestions(name)
end

def self.get_local_suggestions(name)
Drug.where('name ILIKE :name', name: "%#{name}%")

Drug.where('name ILIKE :name', name: "%#{name}%", evidence_items: {status: 'accepted'})
.joins(:evidence_items)
.limit(12)
.distinct
.pluck(:name)
end

Expand Down

0 comments on commit a1a8a03

Please sign in to comment.