-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): updated candidate certification and organism views and rel…
…ated candidate search method to use the certification visible flag
- Loading branch information
Showing
5 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
...rtifications_and_organisms_views_in_order_to_use_certification_visible_flag/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
BEGIN; | ||
|
||
-- Drop view using the OrganismTypology enum | ||
-- available_certification | ||
-- used by candidate app to view available certification | ||
CREATE | ||
OR REPLACE VIEW available_certification_based_on_formacode AS | ||
-- expert filiere and expertBrancheEtFiliere filiere part | ||
SELECT DISTINCT | ||
cer.id as certification_id, | ||
cer.searchable_text as certification_searchable_text | ||
FROM | ||
certification cer, | ||
organism org | ||
LEFT JOIN maison_mere_aap mma ON org.maison_mere_aap_id = mma.id, | ||
formacode code, | ||
organism_on_formacode org_code, | ||
certification_on_formacode cer_code, | ||
organism_on_degree org_degree, | ||
degree degree | ||
WHERE | ||
( | ||
org.typology = 'expertFiliere' | ||
or org.typology = 'expertBrancheEtFiliere' -- "expertBrancheEtFiliere" is both "expertBranche" and "expertFiliere" | ||
) | ||
AND code.type = 'SUB_DOMAIN' | ||
AND mma.is_active = true | ||
AND org.ferme_pour_absence_ou_conges = false | ||
AND cer.visible = true | ||
AND org_code.organism_id = org.id | ||
AND org_code.formacode_id = code.id | ||
AND cer_code.certification_id = cer.id | ||
AND cer_code.formacode_id = code.id | ||
AND org_degree.organism_id = org.id | ||
AND org_degree.degree_id = degree.id | ||
AND degree.level = cer.level | ||
AND NOT EXISTS ( | ||
select | ||
certification_on_ccn.certification_id | ||
from | ||
certification_on_ccn | ||
where | ||
certification_on_ccn.certification_id = cer.id | ||
) | ||
UNION DISTINCT -- | ||
-- expert branche and expertBrancheEtFiliere branche part | ||
SELECT DISTINCT | ||
cer.id as certification_id, | ||
cer.searchable_text as certification_searchable_text | ||
FROM | ||
certification cer, | ||
organism org | ||
LEFT JOIN maison_mere_aap mma ON org.maison_mere_aap_id = mma.id, | ||
convention_collective ccn, | ||
organism_on_ccn org_ccn, | ||
certification_on_ccn cer_ccn, | ||
organism_on_degree org_degree, | ||
degree degree | ||
WHERE | ||
( | ||
org.typology = 'expertBranche' | ||
or org.typology = 'expertBrancheEtFiliere' -- "expertBrancheEtFiliere" is both "expertBranche" and "expertFiliere" | ||
) | ||
AND mma.is_active = true | ||
AND org.ferme_pour_absence_ou_conges = false | ||
AND cer.visible = true | ||
AND org_ccn.organism_id = org.id | ||
AND org_ccn.ccn_id = ccn.id | ||
AND cer_ccn.certification_id = cer.id | ||
AND cer_ccn.ccn_id = ccn.id | ||
AND org_degree.organism_id = org.id | ||
AND org_degree.degree_id = degree.id | ||
AND degree.level = cer.level; | ||
|
||
--active_organism_by_available_certification | ||
--used by candidate app to view active organisms for a given certificate | ||
CREATE | ||
OR REPLACE VIEW active_organism_by_available_certification_based_on_formacode AS | ||
--expert filiere and expertBrancheEtFiliere filiere part | ||
SELECT DISTINCT | ||
org.id as organism_id, | ||
cer.id as certification_id, | ||
cer.searchable_text as certification_searchable_text | ||
FROM | ||
certification cer, | ||
organism org | ||
LEFT JOIN maison_mere_aap mma ON org.maison_mere_aap_id = mma.id, | ||
formacode code, | ||
organism_on_formacode org_code, | ||
certification_on_formacode cer_code, | ||
organism_on_degree org_degree, | ||
degree degree | ||
WHERE | ||
( | ||
org.typology = 'expertFiliere' | ||
or org.typology = 'expertBrancheEtFiliere' -- "expertBrancheEtFiliere" is both "expertBranche" and "expertFiliere" | ||
) | ||
AND code.type = 'SUB_DOMAIN' | ||
AND mma.is_active = true | ||
AND org.ferme_pour_absence_ou_conges = false | ||
AND cer.visible = true | ||
AND org_code.organism_id = org.id | ||
AND org_code.formacode_id = code.id | ||
AND cer_code.certification_id = cer.id | ||
AND cer_code.formacode_id = code.id | ||
AND org_degree.organism_id = org.id | ||
AND org_degree.degree_id = degree.id | ||
AND degree.level = cer.level | ||
AND NOT EXISTS ( | ||
select | ||
certification_on_ccn.certification_id | ||
from | ||
certification_on_ccn | ||
where | ||
certification_on_ccn.certification_id = cer.id | ||
) | ||
UNION DISTINCT -- | ||
-- expert branche and expertBrancheEtFiliere branche part | ||
SELECT DISTINCT | ||
org.id as organisme_id, | ||
cer.id as certification_id, | ||
cer.searchable_text as certification_searchable_text | ||
FROM | ||
certification cer, | ||
organism org | ||
LEFT JOIN maison_mere_aap mma ON org.maison_mere_aap_id = mma.id, | ||
convention_collective ccn, | ||
organism_on_ccn org_ccn, | ||
certification_on_ccn cer_ccn, | ||
organism_on_degree org_degree, | ||
degree degree | ||
WHERE | ||
( | ||
org.typology = 'expertBranche' | ||
or org.typology = 'expertBrancheEtFiliere' -- "expertBrancheEtFiliere" is both "expertBranche" and "expertFiliere" | ||
) | ||
AND mma.is_active = true | ||
AND org.ferme_pour_absence_ou_conges = false | ||
AND cer.visible = true | ||
AND org_ccn.organism_id = org.id | ||
AND org_ccn.ccn_id = ccn.id | ||
AND cer_ccn.certification_id = cer.id | ||
AND cer_ccn.ccn_id = ccn.id | ||
AND org_degree.organism_id = org.id | ||
AND org_degree.degree_id = degree.id | ||
AND degree.level = cer.level; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters