Skip to content

Commit

Permalink
get change in contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenac95 committed Dec 2, 2024
1 parent c7c35d5 commit c4ef1d4
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/lifecycle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ with latest as (
),
0
) as active,
COALESCE(
MAX(
CASE
WHEN classification.metric LIKE 'full_%' THEN amount
END
),
0
) as full,
COALESCE(
MAX(
CASE
WHEN classification.metric LIKE 'full_%' THEN amount
END
),
0
) as part,
COALESCE(
MAX(
CASE
Expand Down Expand Up @@ -62,6 +78,22 @@ previous as (
),
0
) as active,
COALESCE(
MAX(
CASE
WHEN classification.metric LIKE 'full_%' THEN amount
END
),
0
) as full,
COALESCE(
MAX(
CASE
WHEN classification.metric LIKE 'full_%' THEN amount
END
),
0
) as part,
COALESCE(
MAX(
CASE
Expand Down Expand Up @@ -118,6 +150,40 @@ churned_contributors as (
from previous
LEFT JOIN latest ON latest.event_source = previous.event_source
AND @metrics_entity_type_col('to_{entity_type}_id', table_alias := latest) = @metrics_entity_type_col('to_{entity_type}_id', table_alias := previous)
),
change_in_full_time_contributors as (
select @metrics_end('DATE') as metrics_sample_date,
COALESCE(latest.event_source, previous.event_source) as event_source,
@metrics_entity_type_alias(
COALESCE(
@metrics_entity_type_col('to_{entity_type}_id', table_alias := latest),
@metrics_entity_type_col('to_{entity_type}_id', table_alias := previous)
),
'to_{entity_type}_id',
),
'' as from_artifact_id,
@metrics_name('change_in_full_time_contributors') as metric,
COALESCE(latest.full, 0) - COALESCE(previous.full, 0) as amount
from previous
LEFT JOIN latest ON latest.event_source = previous.event_source
AND @metrics_entity_type_col('to_{entity_type}_id', table_alias := latest) = @metrics_entity_type_col('to_{entity_type}_id', table_alias := previous)
),
change_in_part_time_contributors as (
select @metrics_end('DATE') as metrics_sample_date,
COALESCE(latest.event_source, previous.event_source) as event_source,
@metrics_entity_type_alias(
COALESCE(
@metrics_entity_type_col('to_{entity_type}_id', table_alias := latest),
@metrics_entity_type_col('to_{entity_type}_id', table_alias := previous)
),
'to_{entity_type}_id',
),
'' as from_artifact_id,
@metrics_name('change_in_part_time_contributors') as metric,
COALESCE(latest.part, 0) - COALESCE(previous.part, 0) as amount
from previous
LEFT JOIN latest ON latest.event_source = previous.event_source
AND @metrics_entity_type_col('to_{entity_type}_id', table_alias := latest) = @metrics_entity_type_col('to_{entity_type}_id', table_alias := previous)
)
select *
from churned_contributors

0 comments on commit c4ef1d4

Please sign in to comment.