Rename gestionnaire in code to instructeur
This commit is contained in:
parent
6902f84b85
commit
3fde2a6f70
175 changed files with 1162 additions and 1162 deletions
|
@ -1,22 +1,22 @@
|
|||
class DossierSearchService
|
||||
def self.matching_dossiers_for_gestionnaire(search_terms, gestionnaire)
|
||||
dossier_by_exact_id_for_gestionnaire(search_terms, gestionnaire)
|
||||
.presence || dossier_by_full_text_for_gestionnaire(search_terms, gestionnaire)
|
||||
def self.matching_dossiers_for_instructeur(search_terms, instructeur)
|
||||
dossier_by_exact_id_for_instructeur(search_terms, instructeur)
|
||||
.presence || dossier_by_full_text_for_instructeur(search_terms, instructeur)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.dossier_by_exact_id_for_gestionnaire(search_terms, gestionnaire)
|
||||
def self.dossier_by_exact_id_for_instructeur(search_terms, instructeur)
|
||||
id = search_terms.to_i
|
||||
if id != 0 && id_compatible?(id) # Sometimes gestionnaire is searching dossiers with a big number (ex: SIRET), ActiveRecord can't deal with them and throws ActiveModel::RangeError. id_compatible? prevents this.
|
||||
dossiers_by_id(id, gestionnaire)
|
||||
if id != 0 && id_compatible?(id) # Sometimes instructeur is searching dossiers with a big number (ex: SIRET), ActiveRecord can't deal with them and throws ActiveModel::RangeError. id_compatible? prevents this.
|
||||
dossiers_by_id(id, instructeur)
|
||||
else
|
||||
Dossier.none
|
||||
end
|
||||
end
|
||||
|
||||
def self.dossiers_by_id(id, gestionnaire)
|
||||
(gestionnaire.dossiers.where(id: id) + gestionnaire.dossiers_from_avis.where(id: id)).uniq
|
||||
def self.dossiers_by_id(id, instructeur)
|
||||
(instructeur.dossiers.where(id: id) + instructeur.dossiers_from_avis.where(id: id)).uniq
|
||||
end
|
||||
|
||||
def self.id_compatible?(number)
|
||||
|
@ -26,11 +26,11 @@ class DossierSearchService
|
|||
false
|
||||
end
|
||||
|
||||
def self.dossier_by_full_text_for_gestionnaire(search_terms, gestionnaire)
|
||||
def self.dossier_by_full_text_for_instructeur(search_terms, instructeur)
|
||||
ts_vector = "to_tsvector('french', search_terms || private_search_terms)"
|
||||
ts_query = "to_tsquery('french', #{Dossier.connection.quote(to_tsquery(search_terms))})"
|
||||
|
||||
gestionnaire
|
||||
instructeur
|
||||
.dossiers
|
||||
.state_not_brouillon
|
||||
.where("#{ts_vector} @@ #{ts_query}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue