Skip to content

Commit

Permalink
Join politicians, races, and offices to intermediate model
Browse files Browse the repository at this point in the history
  • Loading branch information
wileymc committed Nov 4, 2023
1 parent a37dd3b commit 9b82be5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion models/intermediate/co_boulder_city_filings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ WITH transformed_filings AS (
CASE
WHEN office ILIKE '%City Council%' THEN 'City Council'
END AS political_scope

FROM p6t_state_co.boulder_updated_filings
),

Expand Down Expand Up @@ -45,6 +44,8 @@ transformed_filings_1 AS (

SELECT
tf.*,
p.id AS politician_id,
r.id AS race_id,
tf1.politician_slug,
tf1.politician_slug AS slug,
tf1.election_scope,
Expand All @@ -65,3 +66,22 @@ FROM
p6t_state_co.boulder_updated_filings AS f
LEFT JOIN transformed_filings AS tf ON f.email = tf.email
LEFT JOIN transformed_filings_1 AS tf1 ON tf.email = tf1.email
LEFT JOIN public.politician AS p ON p.slug = tf1.politician_slug
LEFT JOIN
office AS o
ON
o.slug
= SLUGIFY(
CONCAT(
'MN',
' ',
tf.office_title,
' ',
tf.county,
' ',
tf.district,
' ',
tf1.seat
)
)
LEFT JOIN race AS r ON r.office_id = o.id

0 comments on commit 9b82be5

Please sign in to comment.