Skip to content

Commit

Permalink
add: remaining activity based code metrics (#2112)
Browse files Browse the repository at this point in the history
* add: remaining activity based code metrics

* add: gas fees and transactions

* fix: from_id to null and add active addresses
  • Loading branch information
ccerv1 authored Sep 10, 2024
1 parent 0e35e26 commit 95adadb
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 1 deletion.
32 changes: 32 additions & 0 deletions warehouse/metrics_mesh/models/metrics_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,38 @@
ref="forks.sql",
vars={},
),
"commits": MetricQuery(
ref="commits.sql",
vars={},
),
"pull_requests_opened": MetricQuery(
ref="prs_opened.sql",
vars={},
),
"issues_opened": MetricQuery(
ref="issues_opened.sql",
vars={},
),
"pull_requests_merged": MetricQuery(
ref="prs_merged.sql",
vars={},
),
"issues_closed": MetricQuery(
ref="issues_closed.sql",
vars={},
),
"transactions": MetricQuery(
ref="transactions.sql",
vars={},
),
"gas_fees": MetricQuery(
ref="gas_fees.sql",
vars={},
),
"active_addresses": MetricQuery(
ref="active_addresses.sql",
vars={},
),
},
trailing_days=30,
model_options=dict(
Expand Down
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/active_addresses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
COUNT(distinct events.from_artifact_id) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
2 changes: 1 addition & 1 deletion warehouse/metrics_mesh/oso_metrics/active_days.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
events.from_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
COUNT(DISTINCT events.bucket_day) amount,
from metrics.events_daily_to_artifact as events
Expand Down
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/commits.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('COMMIT_CODE')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/gas_fees.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('CONTRACT_INVOCATION_DAILY_L2_GAS_USED')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/issues_closed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('ISSUE_CLOSED')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/issues_opened.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('ISSUE_OPENED')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/prs_merged.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('PULL_REQUEST_MERGED')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/prs_opened.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('PULL_REQUEST_OPENED')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/transactions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type in ('CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT')
and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source

0 comments on commit 95adadb

Please sign in to comment.