-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into disable-invalid-account
- Loading branch information
Showing
109 changed files
with
6,163 additions
and
2,069 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,7 @@ | ||
# dependencies | ||
/node_modules | ||
/frontend/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
/frontend/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
/.env | ||
/.idea/ | ||
/frontend/.env | ||
/dist/ | ||
|
||
# specific files | ||
/server/routers | ||
build/ | ||
dist/ | ||
frontend/src/components/_dsfr/ | ||
frontend/jest.polyfills.js | ||
node_modules/ | ||
public/ | ||
tools/ |
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
25 changes: 25 additions & 0 deletions
25
analytics/dbt/macros/production/events/get_last_establishment_event_status.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,25 @@ | ||
{% macro get_last_establishment_event_status(user_source, event_name, all_users=false) %} | ||
( | ||
SELECT | ||
u.establishment_id, | ||
events.new_status AS status, | ||
events.event_status_label AS status_label, | ||
events.new_occupancy AS occupancy, | ||
events.new_sub_status, | ||
events.created_at, | ||
ROW_NUMBER() OVER (PARTITION BY u.establishment_id ORDER BY events.created_at DESC) AS row_num | ||
FROM {{ ref('int_production_events') }} AS events | ||
LEFT JOIN {{ ref('int_production_users') }} AS u ON events.created_by = u.id | ||
WHERE | ||
1=1 | ||
{% if event_name == 'suivi' %} | ||
AND events.status_changed = TRUE | ||
{% elif event_name == 'occupation' %} | ||
AND events.occupancy_changed = TRUE | ||
{% else %} | ||
{% endif %} | ||
{% if not all_users %} | ||
AND events.user_source = '{{ user_source }}' | ||
{% endif %} | ||
) | ||
{% endmacro %} |
14 changes: 14 additions & 0 deletions
14
analytics/dbt/macros/production/events/select_last_establishment_event.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,14 @@ | ||
{% macro select_last_establishment_event(establishment_table, event_table, column_suffix) %} | ||
( | ||
SELECT | ||
e.id AS establishment_id, | ||
evt.status AS last_event_status_{{ column_suffix }}, | ||
evt.status_label AS last_event_status_label_{{ column_suffix }}, | ||
evt.occupancy AS last_event_occupancy_{{ column_suffix }}, | ||
evt.new_sub_status AS last_event_sub_status_label_{{ column_suffix }}, | ||
evt.created_at AS last_event_date_{{ column_suffix }} | ||
FROM {{ establishment_table }} AS e | ||
LEFT JOIN {{ event_table }} AS evt | ||
ON evt.establishment_id = e.id AND evt.row_num = 1 | ||
) | ||
{% endmacro %} |
20 changes: 20 additions & 0 deletions
20
analytics/dbt/models/intermediate/ff/int_ff_history_housing.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,20 @@ | ||
WITH ff_history as ( | ||
SELECT ff_idlocal, 'ff-' || ff_millesime as file_year, | ||
FROM {{ ref('int_ff_ext_2023') }} | ||
UNION ALL | ||
SELECT ff_idlocal, 'ff-' || ff_millesime as file_year, | ||
FROM {{ ref('int_ff_ext_2022') }} | ||
UNION ALL | ||
SELECT ff_idlocal, 'ff-' || ff_millesime as file_year, | ||
FROM {{ ref('int_ff_ext_2021') }} | ||
UNION ALL | ||
SELECT ff_idlocal, 'ff-' || ff_millesime as file_year, | ||
FROM {{ ref('int_ff_ext_2020') }} | ||
UNION ALL | ||
SELECT ff_idlocal, 'ff-' || ff_millesime as file_year, | ||
FROM {{ ref('int_ff_ext_2019') }}) | ||
SELECT | ||
ff_idlocal as local_id, | ||
listagg(file_year, ',') as file_years, | ||
FROM ff_history lh | ||
GROUP BY local_id |
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
17 changes: 17 additions & 0 deletions
17
...cs/dbt/models/intermediate/production/int_production_establishment_events_last_status.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,17 @@ | ||
WITH | ||
establishment_status_user_followup AS {{ get_last_establishment_event_status('user', 'suivi') }}, | ||
establishment_status_user_occupancy AS {{ get_last_establishment_event_status('user', "occupation") }}, | ||
last_establishment_status_user_followup AS {{ select_last_establishment_event(ref('int_production_establishments'), 'establishment_status_user_followup', 'user_followup') }}, | ||
last_establishment_status_user_occupancy AS {{ select_last_establishment_event(ref('int_production_establishments'), 'establishment_status_user_occupancy', 'user_occupancy') }} | ||
|
||
SELECT | ||
e.id AS establishment_id, | ||
hsuf.last_event_status_user_followup, | ||
hsuf.last_event_status_label_user_followup, | ||
hsuf.last_event_date_user_followup, | ||
hsuf.last_event_sub_status_label_user_followup, | ||
hszo.last_event_occupancy_user_occupancy, | ||
hszo.last_event_date_user_occupancy | ||
FROM {{ ref('int_production_establishments') }} AS e | ||
LEFT JOIN last_establishment_status_user_followup AS hsuf ON e.id = hsuf.establishment_id | ||
LEFT JOIN last_establishment_status_user_occupancy AS hszo ON e.id = hszo.establishment_id |
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
13 changes: 13 additions & 0 deletions
13
analytics/dbt/models/intermediate/production/int_production_housing_establishments.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,13 @@ | ||
|
||
SELECT | ||
ph.id as housing_id, | ||
STRING_AGG(DISTINCT pel.establishment_id, ' | ') as establishment_ids, | ||
ARRAY_AGG(DISTINCT pel.establishment_id) as establishment_ids_array, | ||
CASE SUM(peu.user_number) | ||
WHEN 0 THEN FALSE | ||
ELSE TRUE | ||
END as has_users | ||
FROM {{ ref('int_production_housing') }} as ph | ||
LEFT JOIN {{ ref('int_production_establishments_localities') }} as pel ON pel.geo_code = ph.geo_code | ||
LEFT JOIN {{ ref('int_production_establishments_users') }} as peu ON peu.establishment_id = pel.establishment_id | ||
GROUP BY housing_id |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
WITH ff_data AS ( | ||
SELECT | ||
ff_idlocal, | ||
ff_jdatat AS last_mutation_date, | ||
ff_dcapec2 AS cadastral_classification, | ||
ff_dcntpa AS plot_area, | ||
ff_geomloc AS geometry, | ||
ff_ccthp AS occupancy, | ||
ST_X(ST_Transform(ST_GeomFromWKB(FROM_HEX(ff_geomloc)), 'EPSG:2154', 'EPSG:4326')) AS latitude, | ||
ST_Y(ST_Transform(ST_GeomFromWKB(FROM_HEX(ff_geomloc)), 'EPSG:2154', 'EPSG:4326')) AS longitude | ||
FROM {{ ref('int_ff_ext_2023') }} | ||
), | ||
lovac_2024 AS ( | ||
SELECT | ||
ff_idlocal, | ||
ff_dcntpa AS plot_area, | ||
ff_jdatat AS last_mutation_date, | ||
dvf_datemut AS last_transaction_date, | ||
dvf_valeurfonc AS last_transaction_value, | ||
ffh_ccthp AS occupancy_history, | ||
ban_latitude AS latitude, | ||
ban_longitude AS longitude, | ||
'lovac-2024' AS data_file_years | ||
FROM {{ ref('int_lovac_fil_2024') }} | ||
), | ||
lovac_2023 AS ( | ||
SELECT | ||
ff_idlocal, | ||
ff_dcntpa AS plot_area, | ||
ff_jdatat AS last_mutation_date, | ||
dvf_datemut AS last_transaction_date, | ||
dvf_valeurfonc AS last_transaction_value, | ||
ffh_ccthp AS occupancy_history, | ||
ban_latitude AS latitude, | ||
ban_longitude AS longitude, | ||
'lovac-2023' AS data_file_years | ||
FROM {{ ref('int_lovac_fil_2023') }} | ||
), | ||
lovac_history AS ( | ||
SELECT * FROM {{ ref('int_lovac_history_housing') }} | ||
) | ||
SELECT | ||
COALESCE(l24.ff_idlocal, l23.ff_idlocal, fd.ff_idlocal) AS local_id, | ||
COALESCE(l24.plot_area, l23.plot_area, fd.plot_area) AS plot_area, | ||
fd.cadastral_classification AS cadastral_classification, | ||
COALESCE(l24.latitude, l23.latitude, fd.latitude) AS latitude, | ||
COALESCE(l24.longitude, l23.longitude, fd.longitude) AS longitude, | ||
COALESCE(l24.last_mutation_date, l23.last_mutation_date, fd.last_mutation_date) AS last_mutation_date, | ||
COALESCE(l24.last_transaction_date, l23.last_transaction_date) AS last_transaction_date, | ||
COALESCE(l24.last_transaction_value, l23.last_transaction_value) AS last_transaction_value, | ||
COALESCE(l24.occupancy_history, l23.occupancy_history) AS occupancy_history | ||
FROM ff_data fd | ||
FULL OUTER JOIN lovac_2024 l24 ON fd.ff_idlocal = l24.ff_idlocal | ||
FULL OUTER JOIN lovac_2023 l23 ON COALESCE(fd.ff_idlocal, l24.ff_idlocal) = l23.ff_idlocal |
Oops, something went wrong.