current limit
This commit is contained in:
parent
08258630ed
commit
c6c82579b8
2 changed files with 9 additions and 7 deletions
|
@ -27,20 +27,18 @@ class DossierSearchService
|
|||
end
|
||||
|
||||
def self.dossier_ids_by_full_text(dossiers, search_terms, with_annotations)
|
||||
columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms'
|
||||
|
||||
dossier_by_full_text(dossiers.visible_by_administration, columns, search_terms)
|
||||
dossier_by_full_text(dossiers.visible_by_administration, search_terms, with_annotations:)
|
||||
.pluck('id')
|
||||
.uniq
|
||||
end
|
||||
|
||||
def self.dossier_by_full_text_for_user(search_terms, dossiers)
|
||||
columns = 'search_terms'
|
||||
|
||||
dossier_by_full_text(dossiers.visible_by_user, columns, search_terms)
|
||||
dossier_by_full_text(dossiers.visible_by_user, search_terms)
|
||||
end
|
||||
|
||||
def self.dossier_by_full_text(dossiers, columns, search_terms)
|
||||
def self.dossier_by_full_text(dossiers, search_terms, with_annotations: false)
|
||||
columns = with_annotations ? 'search_terms || private_search_terms' : 'search_terms'
|
||||
|
||||
ts_vector = "to_tsvector('french', unaccent(#{columns}))"
|
||||
ts_query = "to_tsquery('french', unaccent(#{Dossier.connection.quote(to_tsquery(search_terms))}))"
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ describe DossierSearchService do
|
|||
|
||||
# without accent
|
||||
expect(searching('helene')).to eq([dossier.id])
|
||||
|
||||
# NOT WORKING YET
|
||||
# with a single faulty character
|
||||
expect(searching('des pammes')).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue