-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force downcase in MESH authority queries
MESH ids are in lowercase. Since query is case sensitive, we need to downcase query terms in order to prevent false negatives based on typist idiosyncracies. Since it's not possible to redirect authorities in `Qa` due to the `TermsController` behavior (samvera/questioning_authority#137), we simply monkeypatch the existing `Qa::Authorities::Mesh` class.
- Loading branch information
Tom Johnson
committed
Jan 27, 2018
1 parent
8003c4a
commit 5355eda
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'qa/authorities/mesh' | ||
|
||
module Qa | ||
module Authorities | ||
## | ||
# Monkeypatch the built in MESH authority to downcase terms. | ||
# | ||
# @see https://github.com/samvera/questioning_authority/issues/158 | ||
class Mesh | ||
def search(query) | ||
Qa::SubjectMeshTerm | ||
.where('term_lower LIKE ?', "#{query.to_s.downcase}%") | ||
.limit(10) | ||
.map { |t| { id: t.term_id, label: t.term } } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters