-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dbt): add gitcoin funding event data (#2289)
* feat(dbt): add sources and staging models for gitcoin funding events * feat(dbt): map gitcoin projects to oso ids * feat(dbt): add raw gitcoin funding event data
- Loading branch information
Showing
9 changed files
with
119 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sources: | ||
- name: gitcoin | ||
database: opensource-observer | ||
schema: gitcoin | ||
tables: | ||
- name: passport_scores | ||
identifier: passport_scores | ||
- name: all_matching | ||
identifier: all_matching | ||
- name: all_donations | ||
identifier: all_donations | ||
- name: project_lookup | ||
identifier: project_lookup | ||
- name: project_groups_summary | ||
identifier: project_groups_summary |
23 changes: 23 additions & 0 deletions
23
warehouse/dbt/models/intermediate/funding/int_gitcoin_funding_events.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
select | ||
transaction_hash, | ||
donation_timestamp as event_time, | ||
round_id, | ||
round_number, | ||
chain_id, | ||
gitcoin_project_id, | ||
donor_address, | ||
amount_in_usd, | ||
'crowdfunding' as funding_type | ||
from {{ ref('stg_gitcoin__donations') }} | ||
union all | ||
select | ||
null as transaction_hash, | ||
null as event_time, | ||
round_id, | ||
round_number, | ||
chain_id, | ||
gitcoin_project_id, | ||
null as donor_address, | ||
amount_in_usd, | ||
'matching_grant' as funding_type | ||
from {{ ref('stg_gitcoin__matching') }} |
39 changes: 39 additions & 0 deletions
39
warehouse/dbt/models/intermediate/funding/int_gitcoin_project_directory.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
with gitcoin_projects as ( | ||
select distinct | ||
pg.gitcoin_group_id, | ||
pg.latest_project_github, | ||
pg.latest_project_recipient_address, | ||
project_lookup.gitcoin_project_id | ||
from {{ ref('stg_gitcoin__project_groups') }} as pg | ||
left join {{ ref('stg_gitcoin__project_lookup') }} as project_lookup | ||
on pg.gitcoin_group_id = project_lookup.gitcoin_group_id | ||
where not ( | ||
not regexp_contains(pg.latest_project_github, '^[a-zA-Z0-9_-]+$') | ||
or pg.latest_project_github like '%?%' | ||
or pg.latest_project_github = 'none' | ||
or length(pg.latest_project_github) > 39 | ||
) | ||
), | ||
|
||
oso_projects as ( | ||
select distinct | ||
wallets.project_id as oso_project_id, | ||
wallets.artifact_name as address, | ||
repos.artifact_namespace as repo_owner | ||
from {{ ref('int_artifacts_in_ossd_by_project') }} as wallets | ||
cross join {{ ref('int_artifacts_in_ossd_by_project') }} as repos | ||
where | ||
wallets.artifact_type = 'WALLET' | ||
and repos.artifact_source = 'GITHUB' | ||
and wallets.project_id = repos.project_id | ||
) | ||
|
||
select distinct | ||
gitcoin_projects.gitcoin_group_id, | ||
gitcoin_projects.gitcoin_project_id, | ||
oso_projects.oso_project_id | ||
from gitcoin_projects | ||
inner join oso_projects on ( | ||
gitcoin_projects.latest_project_github = oso_projects.repo_owner | ||
and gitcoin_projects.latest_project_recipient_address = oso_projects.address | ||
) |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
warehouse/dbt/models/staging/gitcoin/stg_gitcoin__donations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
select distinct | ||
`source` as gitcoin_data_source, | ||
`timestamp` as donation_timestamp, | ||
round_id, | ||
round_num as round_number, | ||
chain_id, | ||
project_id as gitcoin_project_id, | ||
amount_in_usd, | ||
LOWER(recipient_address) as project_recipient_address, | ||
LOWER(donor_address) as donor_address, | ||
LOWER(transaction_hash) as transaction_hash, | ||
TRIM(project_name) as project_application_title | ||
from {{ source("gitcoin", "all_donations") }} | ||
where amount_in_usd > 0 |
10 changes: 10 additions & 0 deletions
10
warehouse/dbt/models/staging/gitcoin/stg_gitcoin__matching.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
select distinct | ||
round_id as round_id, | ||
round_num as round_number, | ||
chain_id, | ||
project_id as gitcoin_project_id, | ||
match_amount_in_usd as amount_in_usd, | ||
TRIM(title) as round_title, | ||
LOWER(recipient_address) as project_recipient_address | ||
from {{ source("gitcoin", "all_matching") }} | ||
where match_amount_in_usd > 0 |
13 changes: 13 additions & 0 deletions
13
warehouse/dbt/models/staging/gitcoin/stg_gitcoin__project_groups.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
select distinct | ||
group_id as gitcoin_group_id, | ||
latest_created_project_id as latest_gitcoin_project_id, | ||
total_amount_donated as total_amount_donated_in_usd, | ||
application_count as group_application_count, | ||
latest_created_application as latest_project_application_timestamp, | ||
latest_source as latest_gitcoin_data_source, | ||
TRIM(title) as project_application_title, | ||
LOWER(latest_payout_address) as latest_project_recipient_address, | ||
TRIM(LOWER(latest_website)) as latest_project_website, | ||
TRIM(LOWER(latest_project_twitter)) as latest_project_twitter, | ||
TRIM(LOWER(latest_project_github)) as latest_project_github | ||
from {{ source("gitcoin", "project_groups_summary") }} |
5 changes: 5 additions & 0 deletions
5
warehouse/dbt/models/staging/gitcoin/stg_gitcoin__project_lookup.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select distinct | ||
group_id as gitcoin_group_id, | ||
project_id as gitcoin_project_id, | ||
source as latest_gitcoin_data_source | ||
from {{ source("gitcoin", "project_lookup") }} |
File renamed without changes.