Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/recce_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Recce CI

on:
pull_request:
branches: [main]
branches:
- main
paths:
- "dbt/**"

jobs:
check-pull-request:
Expand Down Expand Up @@ -45,14 +48,6 @@ jobs:
run: |
poetry run recce run --cloud

- name: Upload Recce State File
uses: actions/upload-artifact@v4
id: duckdb-uploader
with:
name: duckdb
path: |
jaffle_shop.duckdb

- name: Prepare Recce Summary
id: recce-summary
env:
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Before you begin you'll need the following on your system:

- Python >=3.12 (see [here](https://www.python.org/downloads/))
- Python Poetry >= 1.8 (see [here](https://pypi.org/project/poetry/))
- NPM >= 7 (see [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm))
- git (see [here](https://github.com/git-guides/install-git))

#### Setup dependencies
Expand Down Expand Up @@ -89,3 +90,24 @@ Once you've updated any models you can run dbt _within the poetry environment_ b
```bash
dbt run
```

### Visualize with Evidence

#### Setup Evidence
``` bash
npm --prefix ./evidence install
```

#### Prepare data
``` bash
dbt seed -t prod # Optional
dbt build -t prod # Optional
npm --prefix ./evidence run sources
```

#### Launch Evidence
``` bash
npm --prefix ./evidence run dev
```

![evidence](./gif/advocacy_opposition.gif)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
with presidential_candidates as (
select ac.*
from {{ ref('presidential_candidates') }} pc
left join {{ ref('stg_all_candidates') }} ac
on pc.name = ac.cand_name
)


select
pc.cand_id,
pc.cand_name,
pc.cand_pty_affiliation,
cm.cmte_id,
cm.cmte_nm,
cm.cmte_pty_affiliation,
cc.tran_id,
cc.transaction_tp,
cc.state,
cc.transaction_amt
from presidential_candidates pc
left join {{ ref('stg_contributions_from_committees_to_candidates') }} cc
on pc.cand_id = cc.cand_id
left join {{ ref('stg_committee_master') }} cm
on cc.cmte_id = cm.cmte_id
12 changes: 12 additions & 0 deletions dbt/models/marts/advocacy_opposition_by_state_candidate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
select
cand_name,
transaction_tp,
state,
state in (select abbreviation from {{ ref('swing_states') }}
) as is_swing_state,
count(distinct cmte_id) as cmte_count,
count(*) as transaction_count,
sum(transaction_amt) as total_amt
from {{ ref('int_contributions_to_presidential_candidates') }}
where transaction_tp in ('24A', '24E')
group by cand_name, transaction_tp, state
3 changes: 2 additions & 1 deletion dbt/models/staging/stg_candidate_committee_linkage.sql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
select * from {{ source('s3_datarecce_todofec', 'raw_candidate_committee_linkage') }}
select *
from {{ source('s3_datarecce_todofec', 'raw_candidate_committee_linkage') }}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
select * from {{ source('s3_datarecce_todofec', 'raw_contributions_from_committees_to_candidates') }}
select *
from
{{ source('s3_datarecce_todofec', 'raw_contributions_from_committees_to_candidates') }}
3 changes: 3 additions & 0 deletions dbt/seeds/presidential_candidates.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name
"TRUMP, DONALD J."
"HARRIS, KAMALA"
8 changes: 8 additions & 0 deletions dbt/seeds/swing_states.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
State,Abbreviation
Arizona,AZ
Georgia,GA
Michigan,MI
Nevada,NV
North Carolina,NC
Pennsylvania,PA
Wisconsin,WI
4 changes: 4 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ models:
# Config indicated by + and applies to all files under models/example/
staging:
+materialized: view
intermeidate:
+materialized: view
marts:
+materialized: table
10 changes: 10 additions & 0 deletions evidence/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.evidence/template
.svelte-kit
build
node_modules
.DS_Store
static/data
*.options.yaml
.vscode/settings.json
.env
.evidence/meta
44 changes: 44 additions & 0 deletions evidence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Evidence Template Project

## Using Codespaces

If you are using this template in Codespaces, click the `Start Evidence` button in the bottom status bar. This will install dependencies and open a preview of your project in your browser - you should get a popup prompting you to open in browser.

Or you can use the following commands to get started:

```bash
npm install
npm run sources
npm run dev -- --host 0.0.0.0
```

See [the CLI docs](https://docs.evidence.dev/cli/) for more command information.

**Note:** Codespaces is much faster on the Desktop app. After the Codespace has booted, select the hamburger menu → Open in VS Code Desktop.

## Get Started from VS Code

The easiest way to get started is using the [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=Evidence.evidence-vscode):

1. Install the extension from the VS Code Marketplace
2. Open the Command Palette (Ctrl/Cmd + Shift + P) and enter `Evidence: New Evidence Project`
3. Click `Start Evidence` in the bottom status bar

## Get Started using the CLI

```bash
npx degit evidence-dev/template my-project
cd my-project
npm install
npm run sources
npm run dev
```

Check out the docs for [alternative install methods](https://docs.evidence.dev/getting-started/install-evidence) including Docker, Github Codespaces, and alongside dbt.

## Learning More

- [Docs](https://docs.evidence.dev/)
- [Github](https://github.com/evidence-dev/evidence)
- [Slack Community](https://slack.evidence.dev/)
- [Evidence Home Page](https://www.evidence.dev)
20 changes: 20 additions & 0 deletions evidence/evidence.plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

components:
# This loads all of evidence's core charts and UI components
# You probably don't want to edit this dependency unless you know what you are doing
"@evidence-dev/core-components": {}

datasources:
# You can add additional datasources here by adding npm packages.
# Make to also add them to `package.json`.
# "@evidence-dev/bigquery": { }
# "@evidence-dev/csv": { }
# "@evidence-dev/databricks": { }
"@evidence-dev/duckdb": { }
# "@evidence-dev/mssql": { }
# "@evidence-dev/mysql": { }
# "@evidence-dev/postgres": { }
# "@evidence-dev/snowflake": { }
# "@evidence-dev/sqlite": { }
# "@evidence-dev/trino": { }
# "@evidence-dev/motherduck": { }
Loading