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:
gregoirenovel 2018-10-18 16:16:39 +02:00 committed by GitHub
commit 88538cd959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View file

@ -3,6 +3,10 @@ module NewGestionnaire
def index def index
@search_terms = params[:q] @search_terms = params[:q]
@dossiers = DossierSearchService.matching_dossiers_for_gestionnaire(@search_terms, current_gestionnaire) @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 end
end end

View file

@ -32,7 +32,6 @@ class DossierSearchService
gestionnaire gestionnaire
.dossiers .dossiers
.not_archived
.state_not_brouillon .state_not_brouillon
.where("#{ts_vector} @@ #{ts_query}") .where("#{ts_vector} @@ #{ts_query}")
.order("COALESCE(ts_rank(#{ts_vector}, #{ts_query}), 0) DESC") .order("COALESCE(ts_rank(#{ts_vector}, #{ts_query}), 0) DESC")

View file

@ -14,6 +14,7 @@
%th Démarche %th Démarche
%th Demandeur %th Demandeur
%th.status-col Statut %th.status-col Statut
%th.follow-col
%tbody %tbody
- @dossiers.each do |dossier| - @dossiers.each do |dossier|
/ # FIXME: here we have a n+1, we fire a request / # FIXME: here we have a n+1, we fire a request
@ -30,5 +31,6 @@
%td.status-col %td.status-col
= link_to(dossier_linked_path(current_gestionnaire, dossier), class: 'cell-link') do = link_to(dossier_linked_path(current_gestionnaire, dossier), class: 'cell-link') do
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier } = 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 - else
%h2 Aucun dossier correspondant à votre recherche n'a été trouvé %h2 Aucun dossier correspondant à votre recherche n'a été trouvé

View file

@ -33,7 +33,7 @@ describe DossierSearchService do
let!(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', siret: '41816609600051') } 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_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 describe 'search is empty' do
let(:terms) { '' } let(:terms) { '' }
@ -47,6 +47,12 @@ describe DossierSearchService do
it { expect(subject.size).to eq(0) } it { expect(subject.size).to eq(0) }
end end
describe 'search archived file' do
let(:terms) { 'archived' }
it { expect(subject.size).to eq(1) }
end
describe 'search on contact email' do describe 'search on contact email' do
let(:terms) { 'clap' } let(:terms) { 'clap' }