-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amélioration et historisation des candidats de la file active #382
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
{{ | ||||||
config( | ||||||
materialized='incremental', | ||||||
unique_key=['id', 'semaine_valide'], | ||||||
post_hook=""" | ||||||
DELETE FROM {{ this }} | ||||||
WHERE date_derniere_candidature_acceptee is not null and delai_premiere_candidature > 30 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai mon cerveau qui fume mais |
||||||
""" | ||||||
) | ||||||
}} | ||||||
|
||||||
-- recover last known date in the table to increment for new period | ||||||
with last_known_date as ( | ||||||
select max(date_trunc('week', dbt_valid_to)) as lkd | ||||||
from {{ ref('candidats_recherche_active_snapshot') }} | ||||||
) | ||||||
|
||||||
select | ||||||
{{ pilo_star(ref('candidats_recherche_active_snapshot'), except=["dbt_valid_from", "dbt_valid_to"]) }}, | ||||||
date_trunc('week', week_series) as semaine_valide | ||||||
from | ||||||
{{ ref('candidats_recherche_active_snapshot') }} | ||||||
cross join | ||||||
last_known_date | ||||||
cross join | ||||||
generate_series( | ||||||
date_trunc('week', dbt_valid_from), | ||||||
-- when dbt_valid_to is empty, state is still the same today | ||||||
-- so we compute row for each week from valid_to to today | ||||||
coalesce(date_trunc('week', dbt_valid_to), last_known_date.lkd), | ||||||
interval '1 week' | ||||||
) as week_series | ||||||
|
||||||
{% if is_incremental() %} | ||||||
|
||||||
-- we only update rows that have changed | ||||||
-- the previous state is no longer current if : | ||||||
-- 1: dbt_valid_from is bigger than last week date (this line is the new state) // dbt_valid_from is bigger than the last known date | ||||||
-- 2: dbt_valid_to is bigger than last week date (this line is the last state that is now finished) // dbt_valid | ||||||
where dbt_valid_from >= last_known_date.lkd or dbt_valid_to >= last_known_date.lkd | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Non ? 🤔 |
||||||
|
||||||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- if there is a date_derniere_candidature_acceptee, the candidate is not in the file active | ||
select id | ||
from candidats_recherche_active | ||
where file_active_30_jours = true and date_derniere_candidature_acceptee is not null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C"est la clause
where
de ce fichier qui m'a fait tiquer, mais dans ce modèle faudrait pas remplacer leright join
par uninner join
vu quecandidats_recherche_active.sql
regarderstg_candidats_candidatures
pour savoir si le candidat est dans la fil active ou pas ça ne devrait rien changer, et peut-être aussi virer la clausewhere
pour ne pas dupliquer la logique des 6 mois à plusieurs endroits ?