Skip to content

Commit cb07699

Browse files
authored
Merge pull request #2 from populist-vote/jon_colorado_data
Jon colorado data (boulder)
2 parents 403363e + ac153f6 commit cb07699

19 files changed

+1616
-58
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
WITH transformed_filings AS (
2+
SELECT
3+
email AS email,
4+
first_name AS first_name,
5+
last_name AS last_name,
6+
official_website_url AS official_website_url,
7+
home_state AS home_state,
8+
office AS office,
9+
office AS office_title,
10+
'city wide' AS district,
11+
'Boulder' AS county,
12+
CONCAT(first_name, ' ', last_name) AS candidate_full_name,
13+
CASE
14+
WHEN office ILIKE '%City Council%' THEN 'City Council'
15+
END AS political_scope
16+
FROM p6t_state_co.boulder_updated_filings
17+
),
18+
19+
transformed_filings_1 AS (
20+
SELECT
21+
email,
22+
first_name,
23+
last_name,
24+
official_website_url,
25+
home_state,
26+
office,
27+
candidate_full_name,
28+
political_scope,
29+
'city' AS district_type,
30+
SLUGIFY(candidate_full_name) AS politician_slug,
31+
CASE
32+
WHEN
33+
office ILIKE '%City Council%' OR office ILIKE '%Mayor%'
34+
THEN 'city'
35+
ELSE 'district'
36+
END AS election_scope,
37+
CASE
38+
WHEN office ILIKE '%Mayor%' THEN NULL
39+
ELSE 'At Large'
40+
END AS seat
41+
42+
FROM transformed_filings
43+
)
44+
45+
SELECT
46+
tf.*,
47+
p.id AS politician_id,
48+
r.id AS race_id,
49+
tf1.politician_slug,
50+
tf1.politician_slug AS slug,
51+
tf1.election_scope,
52+
tf1.district_type,
53+
tf1.seat,
54+
SLUGIFY(
55+
tf.home_state
56+
|| ' '
57+
|| tf.office_title
58+
|| ' '
59+
|| tf.county
60+
|| ' '
61+
|| tf.district
62+
|| ' '
63+
|| tf1.seat
64+
) AS office_slug
65+
FROM
66+
p6t_state_co.boulder_updated_filings AS f
67+
LEFT JOIN transformed_filings AS tf ON f.email = tf.email
68+
LEFT JOIN transformed_filings_1 AS tf1 ON tf.email = tf1.email
69+
LEFT JOIN public.politician AS p ON p.slug = tf1.politician_slug
70+
LEFT JOIN
71+
office AS o
72+
ON
73+
o.slug
74+
= SLUGIFY(
75+
CONCAT(
76+
'MN',
77+
' ',
78+
tf.office_title,
79+
' ',
80+
tf.county,
81+
' ',
82+
tf.district,
83+
' ',
84+
tf1.seat
85+
)
86+
)
87+
LEFT JOIN race AS r ON r.office_id = o.id
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT {{ dbt_utils.generate_surrogate_key(['email', 'first_name', 'last_name', 'office']) }} as _surrogate_key, * FROM p6t_state_co.boulder_updated_filings --noqa
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
SELECT DISTINCT ON (office)
2+
'general' AS race_type,
3+
home_state AS state,
4+
FALSE AS is_special_election,
5+
CASE
6+
WHEN office ILIKE '%Mayor%' THEN 'Mayor (Boulder)'
7+
ELSE 'Council Member (Boulder)'
8+
END AS title,
9+
slugify(concat(county, ' ', office_title, ' ', '2023')) AS slug,
10+
CASE
11+
WHEN office ILIKE '%Mayor%' THEN NULL
12+
ELSE 4
13+
END AS num_elect
14+
FROM
15+
{{ ref('co_boulder_city_filings') }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SELECT DISTINCT ON (office_slug)
2+
office_slug AS ref_key,
3+
office_slug AS slug,
4+
home_state AS state,
5+
office_title AS title,
6+
seat,
7+
district,
8+
political_scope AS political_scope,
9+
election_scope AS election_scope,
10+
district_type AS district_type,
11+
'Boulder' AS municipality,
12+
county AS county
13+
FROM
14+
{{ ref('co_boulder_city_filings') }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT DISTINCT ON (politician_slug)
2+
politician_slug AS ref_key,
3+
politician_slug AS slug,
4+
first_name,
5+
last_name,
6+
email,
7+
home_state
8+
FROM
9+
{{ ref ('co_boulder_city_filings') }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT DISTINCT ON (politician_id)
2+
politician_id AS candidate_id,
3+
race_id
4+
FROM
5+
{{ ref('co_boulder_city_filings') }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SELECT DISTINCT ON (office_slug)
2+
office_id AS id,
3+
office_slug AS ref_key,
4+
office_slug AS slug,
5+
state::state,
6+
state_id,
7+
office_title AS title,
8+
seat,
9+
district,
10+
school_district,
11+
political_scope::political_scope,
12+
election_scope::election_scope,
13+
district_type::district_type,
14+
municipality,
15+
county
16+
FROM
17+
{{ ref('mn_sos_local_filings') }}

models/staging/stg_mn_sos_local_races.sql renamed to models/staging/mn/stg_mn_sos_local_races.sql

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,4 @@ SELECT DISTINCT ON (office_id)
77
num_elect::integer,
88
slugify(concat(office_title_raw_no_choice, ' ', '2023')) AS slug
99
FROM
10-
{{ ref('mn_sos_local_filings') }};
11-
12-
13-
{# INSERT INTO race (
14-
title, slug, office_id, race_type, state, is_special_election, num_elect
15-
)
16-
SELECT *
17-
FROM dbt_models.stg_races #}
10+
{{ ref('mn_sos_local_filings') }}

models/staging/stg_mn_sos_local_offices.sql

-50
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Committee Name,Expenditure Amount,Candidate Full Name,Incumbant,Office,District
2+
Coombs for Aurora,22948.61,Alison Coombs,No,Council Member At Large,City Wide
3+
Curtis for Aurora,46238.63,Curtis Gardner,Yes,Council Member At Large,City Wide
4+
Francoise for Aurora,16715.43,Francoise Bergan,Yes,Council Member,Ward 6
5+
Gray for Aurora,4673.6,Jonathan Gray,No,Council Member,Ward 4
6+
Jono Scott for Aurora,12104.16,Jono Scott,No,Mayor,City Wide
7+
Lawson for Aurora City Council,2449.35,Angela Lawson,No,Council Member,Ward 5
8+
Marcano for Aurora,36827.33,Juan Marcano,No,Mayor,City Wide
9+
Mayes for Aurora,18642.86,Thomas Mayes,No,Council Member At Large,City Wide
10+
Mike for Mayor,45464.270000000004,Mike Coffman,Yes,Mayor,City Wide
11+
Rhodes for Aurora,4829.0,Chris Rhodes,No,Council Member,Ward 5
12+
,,Jeffrey Sanford,No,Mayor,City Wide
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
,Ballot Name,Name,Phone,Email Adress,Website,street_address,city,zipcode,state,Office,Filing Date
2+
0,Aaron Brockett,Aaron Brockett,,[email protected],,1601 Yellow Pine Ave,Boulder,80304,CO,Mayor,8-9-2023
3+
1,Aaron Gabriel Neyer,Aaron Neyer,Work: 513-593-1721,[email protected],regenboulder.org,3340 Dover Dr.,Boulder,80305,CO,,
4+
2,Bob Yates,Robert Yates,,[email protected],https://www.bobyatesboulder.com,3820 Cloverleaf Dr,Boulder,80304,CO,Mayor,8-8-2023
5+
3,Jacques Decalo,Jacques Decalo,,[email protected],https://www.jacquesforcouncil.org/,2815 Iliff St,Boulder,80305,CO,City Council,8-9-2023
6+
4,Jenny Robins,Jennifer Robins,,[email protected],jennyforboulder.com,5278 Pinehurst Dr.,Boulder,80301,CO,,
7+
5,Nicole Speer,Nicole Speer,,[email protected],www.nicoleforboulder.com,,Boulder,80305,CO,Mayor,8-8-2023
8+
6,Paul Tweedlie,Paul Tweedlie,,[email protected],,2717 4th Street,Boulder,80304,CO,Mayor,8-28-2023
9+
7,Ryan Schuchard,Ryan Schuchard,Work: 970-5410902,[email protected],,2179 Kincaid Pl.,Boulder,80304,CO,City Council,8-16-2023
10+
8,Silas Atkins,Silas Atkins,,[email protected],silasforboulder.com,3040 Ash Ave,Boulder,80305,CO,City Council,8-16-2023
11+
9,Taishya Adams,Taishya Adams,,[email protected],,2140 Kohler Dr,Boulder,80305,CO,City Council,8-8-2023
12+
10,Tara Winer,Tara Winer,,[email protected],taraforboulder.com,1510 Columbine Ave,Boulder,80302,CO,City Council,8-8-2023
13+
11,Terri Brncic,Terri Brncic,,[email protected],https://www.terri4boulder.com/,3076 9th St,Boulder,80304,CO,City Council,8-10-2023
14+
12,Tina Marquis,Christina Marquis,,[email protected],www.tinaforboulder.com,3091 6th St,Boulder,80304,CO,City Council,8-15-2023
15+
13,Waylon Lewis,Waylon Lewis,,[email protected],,838 University Ave,Boulder,80302,CO,City Council,8-8-2023
16+
14,Keith Pitcher,Keith Pitcher,,,,4621 Gordon Drive,Boulder,80302,CO,,
17+
15,Phillip J. Ziols,Phillip Ziols,,,,3518 Kirkwood Pl.,Boulder,80304,CO,,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
id,email,official_website_url,city,home_state,office,first_name,last_name
2+
0,[email protected],www.tweedlie4bouldermayor.com,Boulder,CO,Mayor,Aaron,Brockett
3+
1,[email protected],regenboulder.org,Boulder,CO,City Council,Aaron,Neyer
4+
2,[email protected],https://www.bobyatesboulder.com,Boulder,CO,Mayor,Robert,Yates
5+
3,[email protected],https://www.jacquesforcouncil.org/,Boulder,CO,City Council,Jacques,Decalo
6+
4,[email protected],jennyforboulder.com,Boulder,CO,City Council,Jennifer,Robins
7+
5,[email protected],www.nicoleforboulder.com,Boulder,CO,Mayor,Nicole,Speer
8+
6,[email protected],,Boulder,CO,Mayor,Paul,Tweedlie
9+
7,[email protected],,Boulder,CO,City Council,Ryan,Schuchard
10+
8,[email protected],silasforboulder.com,Boulder,CO,City Council,Silas,Atkins
11+
9,[email protected],www.adamsforboulder.com,Boulder,CO,City Council,Taishya,Adams
12+
10,[email protected],taraforboulder.com,Boulder,CO,City Council,Tara,Winer
13+
11,[email protected],https://www.terri4boulder.com/,Boulder,CO,City Council,Terri,Brncic
14+
12,[email protected],www.tinaforboulder.com,Boulder,CO,City Council,Christina,Marquis
15+
13,[email protected],,Boulder,CO,City Council,Waylon,Lewis

0 commit comments

Comments
 (0)