Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: oss_funding_v0 model #2655

Merged
merged 3 commits into from
Dec 17, 2024
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
19 changes: 18 additions & 1 deletion apps/docs/docs/integrate/datasets/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,26 @@ where project_name = 'uniswap'

**Remember to replace 'YOUR_PROJECT_NAME' with the name of your project in the query.**

_Note: Unless the model name is versioned, expect that the model is unstable and should not be depended on
_Note: Unless the model name is versioned with a `v1` or higher, expect that the model is unstable and should not be depended on
in a live production application._

Some of our most popular v1 models include:

- `projects_v1`: a list of all projects in the OSO data pipeline
- `artifacts_by_project_v1`: a list of all artifacts owned by a given project
- `projects_by_collection_v1`: a list of all projects in a given collection
- `code_metrics_by_project_v1`: a list of all code metrics for a given project
- `onchain_metrics_by_project_v1`: a list of all onchain metrics for a given project (by chain)

Some of the v0 (WIP) models that we include in analysis but do not recommend for production use:

- `timeseries_events_by_artifact_v0`: a list of all events for a given artifact (our unified event table)
- `oss_funding_v0`: a list of all funding grants to projects, indexed by project and funder
- `repositories_v0`: a list of all GitHub repositories, indexed by project
- `sboms_v0`: a list of package dependencies (software bill of materials), indexed by project
- `package_owners_v0`: a mapping of packages to GitHub repositories, indexed by project
- `contracts_v0`: a list of all discovered contracts, downstream from their deployers and/or factories

### OSO Staging / Intermediate Models

From source data, we produce a "universal event table", currently stored at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ with oss_funding_data as (
'OSS_FUNDING' as event_source,
lower(to_project_name) as to_project_name,
lower(from_funder_name) as from_project_name,
coalesce(amount, 0) as amount
coalesce(amount, 0) as amount,
grant_pool_name,
parse_json(metadata_json) as metadata_json
from {{ source('static_data_sources', 'oss_funding_v1') }}
where
to_project_name is not null
Expand All @@ -31,31 +33,50 @@ gitcoin_data as (
concat('GITCOIN', '_', upper(oso_generated_round_label)) as event_source,
oso_project_name as to_project_name,
'gitcoin' as from_project_name,
amount_in_usd as amount
amount_in_usd as amount,
oso_generated_round_label as grant_pool_name,
to_json(struct(
gitcoin_data_source,
gitcoin_round_id,
round_number,
round_type,
main_round_label,
round_name,
chain_id,
gitcoin_project_id,
project_application_title,
oso_project_id,
oso_display_name,
donor_address
)) as metadata_json
from {{ ref('int_gitcoin_funding_events') }}
),

grants as (
select distinct
select
oss_funding_data.time,
oss_funding_data.event_type,
oss_funding_data.event_source_id,
oss_funding_data.event_source,
oss_funding_data.to_project_name,
oss_funding_data.from_project_name,
oss_funding_data.amount
oss_funding_data.amount,
oss_funding_data.grant_pool_name,
oss_funding_data.metadata_json
from oss_funding_data

union all

select distinct
select
gitcoin_data.time,
gitcoin_data.event_type,
gitcoin_data.event_source_id,
gitcoin_data.event_source,
gitcoin_data.to_project_name,
gitcoin_data.from_project_name,
gitcoin_data.amount
gitcoin_data.amount,
gitcoin_data.grant_pool_name,
gitcoin_data.metadata_json
from gitcoin_data
)

Expand All @@ -70,9 +91,11 @@ select
grants.from_project_name,
from_projects.project_id as from_project_id,
'WALLET' as from_type,
grants.amount
grants.amount,
grants.grant_pool_name,
grants.metadata_json
from grants
inner join {{ ref('projects_v1') }} as to_projects
left join {{ ref('projects_v1') }} as to_projects
on grants.to_project_name = to_projects.project_name
inner join {{ ref('projects_v1') }} as from_projects
on grants.from_project_name = from_projects.project_name
29 changes: 29 additions & 0 deletions warehouse/dbt/models/marts/events/oss_funding_v0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{#
This model is used to store the oss funding grants to project events.
It is WIP and should not be used for production purposes.
#}

{{
config(
materialized='table',
meta = {
'sync_to_db': True,
}
)
}}

select
time,
event_type,
event_source_id,
event_source,
to_project_name,
to_project_id,
to_type,
from_project_name,
from_project_id,
from_type,
amount,
grant_pool_name,
metadata_json
from {{ ref('int_oss_funding_grants_to_project') }}
Loading