Update search view to search v3
This commit is contained in:
parent
93b1fd0da9
commit
81179ceba9
3 changed files with 52 additions and 4 deletions
|
@ -0,0 +1,9 @@
|
|||
class UpdateSearchesToVersion3 < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
replace_view :searches, version: 3
|
||||
end
|
||||
|
||||
def down
|
||||
replace_view :searches, version: 2
|
||||
end
|
||||
end
|
|
@ -609,15 +609,13 @@ ActiveRecord::Schema.define(version: 2018_05_22_142109) do
|
|||
|
||||
create_view "searches", sql_definition: <<-SQL
|
||||
SELECT dossiers.id AS dossier_id,
|
||||
(((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.siren, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.nom, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(rna_informations.association_id, ''::character varying))::text) || ' '::text) || (COALESCE(rna_informations.titre, ''::character varying))::text) || ' '::text) || COALESCE(rna_informations.objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term
|
||||
FROM ((((((((((dossiers
|
||||
(((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term
|
||||
FROM ((((((((dossiers
|
||||
JOIN users ON ((users.id = dossiers.user_id)))
|
||||
LEFT JOIN france_connect_informations ON ((france_connect_informations.user_id = dossiers.user_id)))
|
||||
LEFT JOIN cerfas ON ((cerfas.dossier_id = dossiers.id)))
|
||||
LEFT JOIN champs ON ((champs.dossier_id = dossiers.id)))
|
||||
LEFT JOIN drop_down_lists ON ((drop_down_lists.type_de_champ_id = champs.type_de_champ_id)))
|
||||
LEFT JOIN entreprises ON ((entreprises.dossier_id = dossiers.id)))
|
||||
LEFT JOIN rna_informations ON ((rna_informations.entreprise_id = entreprises.id)))
|
||||
LEFT JOIN etablissements ON ((etablissements.dossier_id = dossiers.id)))
|
||||
LEFT JOIN individuals ON ((individuals.dossier_id = dossiers.id)))
|
||||
LEFT JOIN pieces_justificatives ON ((pieces_justificatives.dossier_id = dossiers.id)));
|
||||
|
|
41
db/views/searches_v03.sql
Normal file
41
db/views/searches_v03.sql
Normal file
|
@ -0,0 +1,41 @@
|
|||
-- this version merges all possible search terms together, complicating the
|
||||
-- view, but enables searching for multiple terms from multiple tables at once.
|
||||
|
||||
SELECT dossiers.id AS dossier_id,
|
||||
COALESCE(users.email, '') || ' ' ||
|
||||
COALESCE(france_connect_informations.given_name, '') || ' ' ||
|
||||
COALESCE(france_connect_informations.family_name, '') || ' ' ||
|
||||
COALESCE(cerfas.content, '') || ' ' ||
|
||||
COALESCE(champs.value, '') || ' ' ||
|
||||
COALESCE(drop_down_lists.value, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_siren, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_nom, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_prenom, '') || ' ' ||
|
||||
COALESCE(etablissements.association_rna, '') || ' ' ||
|
||||
COALESCE(etablissements.association_titre, '') || ' ' ||
|
||||
COALESCE(etablissements.association_objet, '') || ' ' ||
|
||||
COALESCE(etablissements.siret, '') || ' ' ||
|
||||
COALESCE(etablissements.naf, '') || ' ' ||
|
||||
COALESCE(etablissements.libelle_naf, '') || ' ' ||
|
||||
COALESCE(etablissements.adresse, '') || ' ' ||
|
||||
COALESCE(etablissements.code_postal, '') || ' ' ||
|
||||
COALESCE(etablissements.localite, '') || ' ' ||
|
||||
COALESCE(etablissements.code_insee_localite, '') || ' ' ||
|
||||
COALESCE(individuals.nom, '') || ' ' ||
|
||||
COALESCE(individuals.prenom, '') || ' ' ||
|
||||
COALESCE(pieces_justificatives.content, '') AS term
|
||||
FROM dossiers
|
||||
INNER JOIN users ON users.id = dossiers.user_id
|
||||
LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
|
||||
LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id
|
||||
LEFT JOIN champs ON champs.dossier_id = dossiers.id
|
||||
LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
|
||||
LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
|
||||
LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
|
||||
LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id
|
Loading…
Reference in a new issue