Skip to content

Commit

Permalink
add specific columsn in morphology
Browse files Browse the repository at this point in the history
Signed-off-by: Raphaël Courivaud <[email protected]>
  • Loading branch information
rcourivaud committed Feb 6, 2025
1 parent 8547d30 commit c97b852
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
12 changes: 10 additions & 2 deletions analytics/dbt/models/marts/common/marts_common_morphology.sql
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ ff_geo_code_year AS (
production AS (
SELECT
geo_code,
COUNT(h.id) AS housing_count,
SUM(CASE WHEN list_contains(data_file_years, 'lovac-2024') THEN 1 ELSE 0 END) AS housing_last_lovac_count,
SUM(CASE WHEN list_contains(data_file_years, 'ff-2023-locatif') THEN 1 ELSE 0 END) AS housing_last_ff_count,
SUM(CASE WHEN occupancy = 'L' THEN 1 ELSE 0 END) AS housing_rented_count,
SUM(CASE WHEN occupancy = 'V' THEN 1 ELSE 0 END) AS housing_vacant_count,
SUM(CASE WHEN energy_consumption_bdnb IN ('G', 'F') THEN 1 ELSE 0 END) AS housing_energy_sieve_count,
2024 AS year
FROM {{ ref ("int_production_housing") }} as h
WHERE list_contains(data_file_years, 'lovac-2024')
Expand All @@ -229,7 +233,11 @@ SELECT
year
, geo_code
, city_code
, production.housing_count AS count_housing_production
, production.housing_last_lovac_count AS count_housing_last_lovac_production
, production.housing_last_ff_count AS count_housing_last_ff_production
, production.housing_rented_count AS count_housing_rented_production
, production.housing_vacant_count AS count_housing_vacant_production
, production.housing_energy_sieve_count AS count_housing_energy_sieve_production
, lovac.count_vacant_premisses
, lovac.count_vacant_housing
, lovac.count_vacant_housing_private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ SELECT
SUM(count_housing) AS count_housing,
SUM(count_housing_private) AS count_housing_private,
SUM(count_housing_private_rented) AS count_housing_private_rented,
SUM(count_housing_production) AS count_housing_production,
SUM(count_housing_last_lovac_production) AS count_housing_last_lovac_production,
SUM(count_housing_last_ff_production) AS count_housing_last_ff_production,
SUM(count_housing_rented_production) AS count_housing_rented_production,
SUM(count_housing_vacant_production) AS count_housing_vacant_production,
SUM(count_housing_energy_sieve_production) AS count_housing_energy_sieve_production,
SUM(sum_living_area_vacant_housing_private_fil_ccthp) as sum_living_area_vacant_housing_private_fil_ccthp,
SUM(sum_plot_area_vacant_housing_private_fil_ccthp) as sum_plot_area_vacant_housing_private_fil_ccthp
FROM {{ ref ('int_production_establishments') }} pe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,37 @@ WITH base_data AS (
count_housing_private_rented AS count_value
FROM base_data
UNION ALL
-- Production
SELECT
establishment_id,
year,
'count_housing_production' AS count_type,
count_housing_production AS count_value
FROM base_data
'count_housing_last_lovac_production' AS count_type,
count_housing_last_lovac_production AS count_value
FROM base_data,
SELECT
establishment_id,
year,
'count_housing_last_ff_production' AS count_type,
count_housing_last_ff_production AS count_value
FROM base_data,
SELECT
establishment_id,
year,
'count_housing_rented_production' AS count_type,
count_housing_rented_production AS count_value
FROM base_data,
SELECT
establishment_id,
year,
'count_housing_vacant_production' AS count_type,
count_housing_vacant_production AS count_value
FROM base_data,
SELECT
establishment_id,
year,
'count_housing_energy_sieve_production' AS count_type,
count_housing_energy_sieve_production AS count_value
FROM base_data,
)
, pivoted_data AS (
SELECT
Expand Down Expand Up @@ -109,8 +134,20 @@ WITH base_data AS (
count_type = 'count_housing_private_rented'
THEN 'Logements du Parc Privé Loués'
WHEN
count_type = 'count_housing_production'
THEN 'Logements vacants >2 ans - ZLV'
count_type = 'count_housing_last_lovac_production'
THEN 'LOVAC 2024 (>2 ans) - ZLV'
WHEN
count_type = 'count_housing_last_ff_production'
THEN 'FF 2023 (parc privé locatif) - ZLV'
WHEN
count_type = 'count_housing_rented_production'
THEN 'Loué - ZLV'
WHEN
count_type = 'count_housing_vacant_production'
THEN 'Vacant - ZLV'
WHEN
count_type = 'count_housing_energy_sieve_production'
THEN 'Passoire énergétique - ZLV'
END AS count_label,
MAX(CASE WHEN year = 2019 THEN count_value END) AS "2019",
MAX(CASE WHEN year = 2020 THEN count_value END) AS "2020",
Expand Down
2 changes: 1 addition & 1 deletion analytics/dbt/target/manifest.json

Large diffs are not rendered by default.

0 comments on commit c97b852

Please sign in to comment.