Merge pull request #2876 from betagouv/frederic/fix_2874-recherche_dossiers_archives
Fix #2874 remonter les dossiers archives dans les résultats de recherche
This commit is contained in:
commit
88538cd959
4 changed files with 13 additions and 2 deletions
|
@ -3,6 +3,10 @@ module NewGestionnaire
|
|||
def index
|
||||
@search_terms = params[:q]
|
||||
@dossiers = DossierSearchService.matching_dossiers_for_gestionnaire(@search_terms, current_gestionnaire)
|
||||
@followed_dossiers_id = current_gestionnaire
|
||||
.followed_dossiers
|
||||
.where(procedure_id: @dossiers.pluck(:procedure_id))
|
||||
.pluck(:id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,6 @@ class DossierSearchService
|
|||
|
||||
gestionnaire
|
||||
.dossiers
|
||||
.not_archived
|
||||
.state_not_brouillon
|
||||
.where("#{ts_vector} @@ #{ts_query}")
|
||||
.order("COALESCE(ts_rank(#{ts_vector}, #{ts_query}), 0) DESC")
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
%th Démarche
|
||||
%th Demandeur
|
||||
%th.status-col Statut
|
||||
%th.follow-col
|
||||
%tbody
|
||||
- @dossiers.each do |dossier|
|
||||
/ # FIXME: here we have a n+1, we fire a request
|
||||
|
@ -30,5 +31,6 @@
|
|||
%td.status-col
|
||||
= link_to(dossier_linked_path(current_gestionnaire, dossier), class: 'cell-link') do
|
||||
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
|
||||
%td.follow-col= render partial: 'new_gestionnaire/procedures/dossier_actions', locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
|
||||
- else
|
||||
%h2 Aucun dossier correspondant à votre recherche n'a été trouvé
|
||||
|
|
|
@ -33,7 +33,7 @@ describe DossierSearchService do
|
|||
let!(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', siret: '41816609600051') }
|
||||
let!(:dossier_3) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) }
|
||||
|
||||
let!(:dossier_archived) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
let!(:dossier_archived) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, archived: true, user: create(:user, email: 'archived@clap.fr')) }
|
||||
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
|
@ -47,6 +47,12 @@ describe DossierSearchService do
|
|||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search archived file' do
|
||||
let(:terms) { 'archived' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
describe 'search on contact email' do
|
||||
let(:terms) { 'clap' }
|
||||
|
||||
|
|
Loading…
Reference in a new issue