diff --git a/warehouse/dbt/models/intermediate/metrics/int_metrics.sql b/warehouse/dbt/models/intermediate/metrics/int_metrics.sql new file mode 100644 index 000000000..8a226f1f4 --- /dev/null +++ b/warehouse/dbt/models/intermediate/metrics/int_metrics.sql @@ -0,0 +1,11 @@ +select + {{ oso_id('"OSO"', '"oso"', 'metric') }} as metric_id, + "OSO" as metric_source, + "oso" as metric_namespace, + metrics.metric as metric_name, + "TODO" as display_name, + "TODO" as description, + null as raw_definition, + "TODO" as definition_ref, + "UNKNOWN" as aggregation_function +from {{ ref('int_timeseries_code_metrics_by_artifact__developers') }} as metrics diff --git a/warehouse/dbt/models/intermediate/metrics/int_timeseries_code_metrics_by_project.sql b/warehouse/dbt/models/intermediate/metrics/int_timeseries_code_metrics_by_project.sql deleted file mode 100644 index 1e4d691cc..000000000 --- a/warehouse/dbt/models/intermediate/metrics/int_timeseries_code_metrics_by_project.sql +++ /dev/null @@ -1,33 +0,0 @@ -{{ - config( - materialized='table' - ) -}} - -with metrics as ( - select * from {{ ref('int_timeseries_code_metrics__developers') }} -), - -project_metadata as ( - select - project_id, - project_source, - project_namespace, - project_name, - display_name - from {{ ref('int_projects') }} -) - -select - project_metadata.project_id, - project_metadata.project_source, - project_metadata.project_namespace, - project_metadata.project_name, - project_metadata.display_name, - metrics.event_source, - metrics.bucket_day, - metrics.metric, - metrics.amount -from metrics -left join project_metadata - on metrics.project_id = project_metadata.project_id diff --git a/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_artifact.sql b/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_artifact.sql new file mode 100644 index 000000000..872c704db --- /dev/null +++ b/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_artifact.sql @@ -0,0 +1,7 @@ +select + {{ oso_id('"OSO"', '"oso"', 'metric') }} as metric_id, + metrics.to_artifact_id as artifact_id, + metrics.bucket_day as sample_date, + metrics.amount as amount, + null as unit +from {{ ref('int_timeseries_code_metrics_by_artifact__developers') }} as metrics diff --git a/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_project.sql b/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_project.sql new file mode 100644 index 000000000..551645bfe --- /dev/null +++ b/warehouse/dbt/models/intermediate/metrics/int_timeseries_metrics_by_project.sql @@ -0,0 +1,14 @@ +{{ + config( + materialized='table' + ) +}} + + +select + {{ oso_id('"OSO"', '"oso"', 'metric') }} as metric_id, + metrics.project_id as project_id, + metrics.bucket_day as sample_date, + metrics.amount as amount, + null as unit +from {{ ref('int_timeseries_code_metrics__developers') }} as metrics diff --git a/warehouse/dbt/models/marts/directory/metrics_v0.sql b/warehouse/dbt/models/marts/directory/metrics_v0.sql new file mode 100644 index 000000000..4e1c8b6b1 --- /dev/null +++ b/warehouse/dbt/models/marts/directory/metrics_v0.sql @@ -0,0 +1,21 @@ +{{ + config(meta = { + 'sync_to_db': True, + 'index': { + 'idx_metric_id': ["metric_id"], + 'idx_metric_name': ["metric_source", "metric_namespace", "metric_name"], + } + }) +}} + +select + metrics.metric_id, + metrics.metric_source, + metrics.metric_namespace, + metrics.metric_name, + metrics.display_name, + metrics.description, + metrics.raw_definition, + metrics.definition_ref, + metrics.aggregation_function +from {{ ref('int_metrics') }} as metrics diff --git a/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_artifact_v0.sql b/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_artifact_v0.sql new file mode 100644 index 000000000..a37b1cfe3 --- /dev/null +++ b/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_artifact_v0.sql @@ -0,0 +1,7 @@ +select + metric_id, + artifact_id, + sample_date, + amount, + unit +from {{ ref('int_timeseries_metrics_by_artifact') }} diff --git a/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_project_v0.sql b/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_project_v0.sql new file mode 100644 index 000000000..7dcd116fe --- /dev/null +++ b/warehouse/dbt/models/marts/metrics/timeseries_metrics_by_project_v0.sql @@ -0,0 +1,7 @@ +select + metric_id, + project_id, + sample_date, + amount, + unit +from {{ ref('int_timeseries_metrics_by_project') }}