Skip to content

Commit

Permalink
feat(dbt): add gitcoin funding event data (#2289)
Browse files Browse the repository at this point in the history
* 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
ccerv1 authored Oct 2, 2024
1 parent cb91442 commit df1ef3f
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 8 deletions.
15 changes: 15 additions & 0 deletions warehouse/dbt/models/gitcoin_sources.yml
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
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') }}
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
)
8 changes: 0 additions & 8 deletions warehouse/dbt/models/passport_sources.yml

This file was deleted.

14 changes: 14 additions & 0 deletions warehouse/dbt/models/staging/gitcoin/stg_gitcoin__donations.sql
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 warehouse/dbt/models/staging/gitcoin/stg_gitcoin__matching.sql
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
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") }}
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") }}

0 comments on commit df1ef3f

Please sign in to comment.