From 361cad95d2388d67aa598fabb32f3641366b6c26 Mon Sep 17 00:00:00 2001 From: Willy Raedy Date: Wed, 12 Nov 2025 15:45:36 -0600 Subject: [PATCH 1/4] fix survey response noin --- .../int_ngpvan__01__survey_responses.sql | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql index b6d6d43..09d9609 100644 --- a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql +++ b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql @@ -105,22 +105,27 @@ WITH contacts.segment_by {{ ngpvan__int__additional_fields() }} FROM contacts + LEFT JOIN committees + ON committees.committee_id = contacts.committee_id LEFT JOIN responses ON contacts.survey_question_id = responses.survey_question_id AND contacts.survey_response_id = responses.survey_response_id - AND contacts.committee_id = responses.survey_response_committee_id - AND contacts.segment_by = responses.segment_by + AND ( + contacts.committee_id = responses.survey_response_committee_id + OR commitees.parent_commitee_id = responses.survey_response_committee_id + ) LEFT JOIN questions ON contacts.survey_question_id = questions.survey_question_id - AND contacts.committee_id = questions.survey_question_committee_id - AND contacts.segment_by = questions.segment_by - LEFT JOIN committees - ON (committees.committee_id = COALESCE(contacts.committee_id, questions.survey_question_committee_id, responses.survey_response_committee_id)) - AND committees.segment_by = contacts.segment_by + AND ( + contacts.committee_id = questions.survey_question_committee_id + OR commitees.parent_commitee_id = questions.survey_question_committee_id + ) LEFT JOIN campaigns ON contacts.campaign_id = campaigns.campaign_id - AND contacts.committee_id = campaigns.committee_id - AND contacts.segment_by = campaigns.segment_by + AND ( + contacts.committee_id = campaigns.committee_id + OR commitees.parent_commitee_id = campaigns.committee_id + ) ) SELECT * FROM survey_responses From d71b38db565cbbf05b3b40e540f6366c2edb78be Mon Sep 17 00:00:00 2001 From: Willy Raedy Date: Wed, 12 Nov 2025 15:59:58 -0600 Subject: [PATCH 2/4] fix parent commitee typo --- .../ngpvan/int_ngpvan__01__survey_responses.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql index 09d9609..a382e95 100644 --- a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql +++ b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql @@ -43,6 +43,7 @@ WITH committee_name, committee_short_name, committee_type, + parent_committee_id, segment_by FROM {{ ref("stg_ngpvan__committees") }} ), @@ -112,19 +113,19 @@ WITH AND contacts.survey_response_id = responses.survey_response_id AND ( contacts.committee_id = responses.survey_response_committee_id - OR commitees.parent_commitee_id = responses.survey_response_committee_id + OR commitees.parent_committee_id = responses.survey_response_committee_id ) LEFT JOIN questions ON contacts.survey_question_id = questions.survey_question_id AND ( contacts.committee_id = questions.survey_question_committee_id - OR commitees.parent_commitee_id = questions.survey_question_committee_id + OR commitees.parent_committee_id = questions.survey_question_committee_id ) LEFT JOIN campaigns ON contacts.campaign_id = campaigns.campaign_id AND ( contacts.committee_id = campaigns.committee_id - OR commitees.parent_commitee_id = campaigns.committee_id + OR commitees.parent_committee_id = campaigns.committee_id ) ) From 2a6c6c8e48e5ade6069921c2611e4351682b7a3e Mon Sep 17 00:00:00 2001 From: Willy Raedy Date: Wed, 12 Nov 2025 16:00:23 -0600 Subject: [PATCH 3/4] fix typo --- .../ngpvan/int_ngpvan__01__survey_responses.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql index a382e95..acf9eab 100644 --- a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql +++ b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql @@ -113,19 +113,19 @@ WITH AND contacts.survey_response_id = responses.survey_response_id AND ( contacts.committee_id = responses.survey_response_committee_id - OR commitees.parent_committee_id = responses.survey_response_committee_id + OR committees.parent_committee_id = responses.survey_response_committee_id ) LEFT JOIN questions ON contacts.survey_question_id = questions.survey_question_id AND ( contacts.committee_id = questions.survey_question_committee_id - OR commitees.parent_committee_id = questions.survey_question_committee_id + OR committees.parent_committee_id = questions.survey_question_committee_id ) LEFT JOIN campaigns ON contacts.campaign_id = campaigns.campaign_id AND ( contacts.committee_id = campaigns.committee_id - OR commitees.parent_committee_id = campaigns.committee_id + OR committtees.parent_committee_id = campaigns.committee_id ) ) From 762d0083ab0a553dff401c9c01d44be00096a8d6 Mon Sep 17 00:00:00 2001 From: Willy Raedy Date: Wed, 12 Nov 2025 16:07:44 -0600 Subject: [PATCH 4/4] typo --- models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql index acf9eab..93a6df2 100644 --- a/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql +++ b/models/intermediate/ngpvan/int_ngpvan__01__survey_responses.sql @@ -125,7 +125,7 @@ WITH ON contacts.campaign_id = campaigns.campaign_id AND ( contacts.committee_id = campaigns.committee_id - OR committtees.parent_committee_id = campaigns.committee_id + OR committees.parent_committee_id = campaigns.committee_id ) )