refactor: update app code for domain-scoped schema migration
Some checks failed
CI / lint-and-test (pull_request) Has been cancelled

- Update dbt model references to use new schema naming (stg_toronto, int_toronto, mart_toronto)
- Refactor figure factories to use consistent column naming from new schema
- Update callbacks to work with refactored data structures
- Add centralized design tokens module for consistent styling
- Streamline CLAUDE.md documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 17:00:30 -05:00
parent cda2a078d9
commit dfa5f92d8a
21 changed files with 618 additions and 407 deletions

View File

@@ -5,11 +5,11 @@ models:
description: "Rental data enriched with time and zone dimensions"
columns:
- name: rental_id
tests:
data_tests:
- unique
- not_null
- name: zone_code
tests:
data_tests:
- not_null
- name: int_neighbourhood__demographics
@@ -17,11 +17,11 @@ models:
columns:
- name: neighbourhood_id
description: "Neighbourhood identifier"
tests:
data_tests:
- not_null
- name: census_year
description: "Census year"
tests:
data_tests:
- not_null
- name: income_quintile
description: "Income quintile (1-5, city-wide)"
@@ -31,7 +31,7 @@ models:
columns:
- name: neighbourhood_id
description: "Neighbourhood identifier"
tests:
data_tests:
- not_null
- name: year
description: "Reference year"
@@ -45,11 +45,11 @@ models:
columns:
- name: neighbourhood_id
description: "Neighbourhood identifier"
tests:
data_tests:
- not_null
- name: year
description: "Statistics year"
tests:
data_tests:
- not_null
- name: crime_rate_per_100k
description: "Total crime rate per 100K population"
@@ -61,7 +61,7 @@ models:
columns:
- name: neighbourhood_id
description: "Neighbourhood identifier"
tests:
data_tests:
- not_null
- name: year
description: "Reference year"
@@ -75,11 +75,11 @@ models:
columns:
- name: neighbourhood_id
description: "Neighbourhood identifier"
tests:
data_tests:
- not_null
- name: year
description: "Survey year"
tests:
data_tests:
- not_null
- name: avg_rent_2bed
description: "Weighted average 2-bedroom rent"

View File

@@ -16,12 +16,12 @@ crime_by_year as (
neighbourhood_id,
crime_year as year,
sum(incident_count) as total_incidents,
sum(case when crime_type = 'Assault' then incident_count else 0 end) as assault_count,
sum(case when crime_type = 'Auto Theft' then incident_count else 0 end) as auto_theft_count,
sum(case when crime_type = 'Break and Enter' then incident_count else 0 end) as break_enter_count,
sum(case when crime_type = 'Robbery' then incident_count else 0 end) as robbery_count,
sum(case when crime_type = 'Theft Over' then incident_count else 0 end) as theft_over_count,
sum(case when crime_type = 'Homicide' then incident_count else 0 end) as homicide_count,
sum(case when crime_type = 'assault' then incident_count else 0 end) as assault_count,
sum(case when crime_type = 'auto_theft' then incident_count else 0 end) as auto_theft_count,
sum(case when crime_type = 'break_and_enter' then incident_count else 0 end) as break_enter_count,
sum(case when crime_type = 'robbery' then incident_count else 0 end) as robbery_count,
sum(case when crime_type = 'theft_over' then incident_count else 0 end) as theft_over_count,
sum(case when crime_type = 'homicide' then incident_count else 0 end) as homicide_count,
avg(rate_per_100k) as avg_rate_per_100k
from crime
group by neighbourhood_id, crime_year

View File

@@ -42,10 +42,10 @@ pivoted as (
select
neighbourhood_id,
year,
max(case when bedroom_type = 'Two Bedroom' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_2bed,
max(case when bedroom_type = 'One Bedroom' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_1bed,
max(case when bedroom_type = 'Bachelor' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_bachelor,
max(case when bedroom_type = 'Three Bedroom +' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_3bed,
max(case when bedroom_type = '2bed' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_2bed,
max(case when bedroom_type = '1bed' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_1bed,
max(case when bedroom_type = 'bachelor' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_bachelor,
max(case when bedroom_type = '3bed' then weighted_avg_rent / nullif(total_weight, 0) end) as avg_rent_3bed,
avg(vacancy_rate) as vacancy_rate,
sum(rental_units_estimate) as total_rental_units
from allocated