Skip to content

Commit

Permalink
feat: add oss checks (WIP) to rf4 metrics mart (#1550)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccerv1 committed May 28, 2024
1 parent 0a79d92 commit 32e2ea4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 5 additions & 6 deletions apps/docs/docs/how-oso-works/impact-metrics/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ An impact metric must be:

## Schema

Every impact metric must include the following fields: `project_id`, `event_source`, `time_interval`, `impact_metric`, and `amount`. For example:
Every impact metric must include the following fields: `project_id`, `impact_metric`, and `amount`. For example:
```json
{
"project_id": "jUda1pi-FdNlaUmgKq51B4h8x4wX3QTN2fZkKq6N0vw\u003d",
"event_source": "GITHUB",
"time_interval": "6 MONTHS",
"impact_metric": "fork_count",
"amount": 125
"impact_metric": "fork_count_6_months",
"amount": "125.0"
}
```

Some may also include a `namespace` field to be explicit about the source of the event data to calculate the impact metric. This is useful, for instance, in the case of projects on multiple blockchain networks.
Currently all intermediate metrics are calculated [here](https://github.com/opensource-observer/oso/tree/main/warehouse/dbt/models/intermediate/metrics) and consolidated metrics are available as metrics marts [here](https://github.com/opensource-observer/oso/tree/main/warehouse/dbt/models/marts/metrics).


## Sample Metrics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pivot_metrics as (
select
pivot_metrics.project_id,
projects_v1.project_name,
rf4_project_verification.check_oss_requirements,
pivot_metrics.gas_fees,
pivot_metrics.transaction_count,
pivot_metrics.trusted_transaction_count,
Expand All @@ -93,3 +94,5 @@ select
from pivot_metrics
left join {{ ref('projects_v1') }}
on pivot_metrics.project_id = projects_v1.project_id
left join {{ ref('rf4_project_verification') }}
on pivot_metrics.project_id = rf4_project_verification.project_id
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ checks as (
unique_addresses,
date_first_transaction,
days_with_onchain_activity_in_range,
ARRAY_LENGTH(eligible_repos) >= 1 as check_eligible_repos,
ARRAY_LENGTH(eligible_repos) >= 1 as check_oss_requirements,
unique_addresses >= 420 as check_unique_addresses,
date_first_transaction < '2024-03-01' as check_date_first_transaction,
days_with_onchain_activity_in_range >= 10
Expand All @@ -77,13 +77,12 @@ select
unique_addresses,
date_first_transaction,
days_with_onchain_activity_in_range,
check_eligible_repos,
check_oss_requirements,
check_unique_addresses,
check_date_first_transaction,
check_days_with_onchain_activity_in_range,
(
check_eligible_repos
and check_unique_addresses
check_unique_addresses
and check_date_first_transaction
and check_days_with_onchain_activity_in_range
) as meets_all_requirements
Expand Down

0 comments on commit 32e2ea4

Please sign in to comment.