Merged PR 5055: KPIs models for API Billable Verifications
# Description Changes: * 4 new models in the scope of KPIs for Billable Verifications from APIs. I believe it's more correct to say these are Billable Verifications than Billable Bookings since there's some cases in which a Booking can be duplicated and it's billed multiple times. These include: * A daily metric model - extremely simple. You will notice there's no Billing Country not Listing Segmentation. This is because for ALL API cases this is UNSET, thus, I just remove it. * An equivalent monthly metric model. * Two aggregated models per dimension, dimension value: on a daily and a monthly basis. Important change: the macro that handles the aggregations sets by default Billing Country and Listing Segmentation. I modified a bit the flow so the only required dimension is Global, and these are skipped for APIs models. This is needed for the changes intended on the Growth score. In there, I'll combine both Platform Billable Bookings with API Billable Verifications. Notice there's no MTD models. These could be added for sure; but since I'm not creating any metric in Main KPIs or similar, I opted to skip it for now. It can be done later on. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #29374
This commit is contained in:
parent
653666abad
commit
9be6ec1dae
6 changed files with 337 additions and 3 deletions
|
|
@ -0,0 +1,19 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("API_BILLABLE_VERIFICATIONS") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
||||
{% for dimension in dimensions %}
|
||||
select
|
||||
-- Unique Key --
|
||||
date,
|
||||
{{ dimension.dimension }} as dimension,
|
||||
{{ dimension.dimension_value }} as dimension_value,
|
||||
-- Metrics --
|
||||
sum(billable_verifications) as billable_verifications
|
||||
from {{ ref("int_kpis__metric_daily_api_billable_verifications") }}
|
||||
group by 1, 2, 3
|
||||
{% if not loop.last %}
|
||||
union all
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("API_BILLABLE_VERIFICATIONS") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
materialized="table", unique_key=["end_date", "dimension", "dimension_value"]
|
||||
)
|
||||
}}
|
||||
|
||||
|
||||
{% for dimension in dimensions %}
|
||||
select
|
||||
-- Unique Key --
|
||||
start_date,
|
||||
end_date,
|
||||
{{ dimension.dimension }} as dimension,
|
||||
{{ dimension.dimension_value }} as dimension_value,
|
||||
-- Metrics --
|
||||
sum(billable_verifications) as billable_verifications
|
||||
from {{ ref("int_kpis__metric_monthly_api_billable_verifications") }}
|
||||
group by 1, 2, 3, 4
|
||||
{% if not loop.last %}
|
||||
union all
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{{ config(materialized="table", unique_key=["date", "id_deal", "service_name"]) }}
|
||||
|
||||
select
|
||||
-- Unique Key --
|
||||
iuav.billable_date_utc as date,
|
||||
coalesce(iuav.id_deal, 'UNSET') as id_deal,
|
||||
coalesce(iuav.api_source, 'UNSET') as service_name,
|
||||
-- Dimensions --
|
||||
'API' as business_scope,
|
||||
-- Metrics --
|
||||
count(distinct iuav.id_verification) as billable_verifications
|
||||
from {{ ref("int_unified_api_verifications") }} iuav
|
||||
where iuav.billable_date_utc is not null
|
||||
group by 1, 2, 3, 4
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{{
|
||||
config(
|
||||
materialized="view",
|
||||
unique_key=[
|
||||
"end_date",
|
||||
"id_deal",
|
||||
"service_name",
|
||||
],
|
||||
)
|
||||
}}
|
||||
|
||||
select
|
||||
-- Unique Key --
|
||||
d.first_day_month as start_date,
|
||||
d.date as end_date,
|
||||
b.id_deal,
|
||||
b.service_name,
|
||||
-- Dimensions --
|
||||
b.business_scope,
|
||||
-- Metrics --
|
||||
sum(b.billable_verifications) as billable_verifications
|
||||
from {{ ref("int_kpis__dimension_dates") }} d
|
||||
left join
|
||||
{{ ref("int_kpis__metric_daily_api_billable_verifications") }} b
|
||||
on date_trunc('month', b.date)::date = d.first_day_month
|
||||
where d.is_end_of_month = true and b.id_deal is not null
|
||||
group by 1, 2, 3, 4, 5
|
||||
|
|
@ -8834,3 +8834,233 @@ models:
|
|||
- Rolling up the total onboarding MRR for each listing segment to get the total onboarding MRR
|
||||
for the Global dimension.
|
||||
This is not available for 'by_billing_country' dimension, thus null values are expected.
|
||||
|
||||
- name: int_kpis__metric_daily_api_billable_verifications
|
||||
description: |
|
||||
This model computes the Daily Billable Verifications from APIs at
|
||||
the deepest granularity.
|
||||
|
||||
The unique key corresponds to the deepest granularity of the model,
|
||||
in this case:
|
||||
- date,
|
||||
- id_deal,
|
||||
- service_name.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- id_deal
|
||||
- service_name
|
||||
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: Date of when Verifications have been billable.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: Unique identifier of an account.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: business_scope
|
||||
data_type: string
|
||||
description: |
|
||||
Business scope identifying the metric source.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "API"
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
Name of the API service that has been billable.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "ATHENA"
|
||||
- "E-DEPOSIT"
|
||||
- "CHECK_IN_HERO"
|
||||
- "SCREEN_AND_PROTECT"
|
||||
|
||||
- name: billable_verifications
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of daily verifications billable in a given date and per specified dimension.
|
||||
|
||||
- name: int_kpis__agg_daily_api_billable_verifications
|
||||
description: |
|
||||
This model computes the dimension aggregation for
|
||||
Daily Billable Verifications, from APIs.
|
||||
|
||||
The primary key of this model is date, dimension
|
||||
and dimension_value.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- dimension
|
||||
- dimension_value
|
||||
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: |
|
||||
The start and end date of the time range considered for
|
||||
the metrics in this record.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: dimension
|
||||
data_type: string
|
||||
description: The dimension or granularity of the metrics.
|
||||
data_tests:
|
||||
- assert_dimension_completeness:
|
||||
metric_column_names:
|
||||
- billable_verifications
|
||||
- accepted_values:
|
||||
values:
|
||||
- global
|
||||
- by_service
|
||||
- by_business_scope
|
||||
- by_deal
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
description: The value or segment available for the selected dimension.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: billable_verifications
|
||||
data_type: bigint
|
||||
description: The daily billable verifications for a given date, dimension and value.
|
||||
|
||||
- name: int_kpis__metric_monthly_api_billable_verifications
|
||||
description: |
|
||||
This model computes the Monthly Billable Verifications from APIs at
|
||||
the deepest granularity.
|
||||
|
||||
The unique key corresponds to the deepest granularity of the model,
|
||||
in this case:
|
||||
- end_date,
|
||||
- id_deal,
|
||||
- service_name.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- end_date
|
||||
- id_deal
|
||||
- service_name
|
||||
|
||||
columns:
|
||||
- name: start_date
|
||||
data_type: date
|
||||
description: |
|
||||
The start date of the time range considered for the metrics in this record.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: end_date
|
||||
data_type: date
|
||||
description: |
|
||||
The end date of the time range considered for the metrics in this record.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: Unique identifier of an account.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: business_scope
|
||||
data_type: string
|
||||
description: |
|
||||
Business scope identifying the metric source.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "API"
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
Name of the API service that has been billable.
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "ATHENA"
|
||||
- "E-DEPOSIT"
|
||||
- "CHECK_IN_HERO"
|
||||
- "SCREEN_AND_PROTECT"
|
||||
|
||||
- name: billable_verifications
|
||||
data_type: bigint
|
||||
description: |
|
||||
Count of monthly verifications billable in a given month and per
|
||||
specified dimension.
|
||||
|
||||
- name: int_kpis__agg_monthly_api_billable_verifications
|
||||
description: |
|
||||
This model computes the dimension aggregation for
|
||||
Monthly Billable Verifications, from APIs.
|
||||
|
||||
The primary key of this model is end_date, dimension
|
||||
and dimension_value.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- end_date
|
||||
- dimension
|
||||
- dimension_value
|
||||
|
||||
columns:
|
||||
- name: start_date
|
||||
data_type: date
|
||||
description: |
|
||||
The start date of the time range considered for the metrics in this record.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: end_date
|
||||
data_type: date
|
||||
description: |
|
||||
The end date of the time range considered for the metrics in this record.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: dimension
|
||||
data_type: string
|
||||
description: The dimension or granularity of the metrics.
|
||||
data_tests:
|
||||
- assert_dimension_completeness:
|
||||
metric_column_names:
|
||||
- billable_verifications
|
||||
- accepted_values:
|
||||
values:
|
||||
- global
|
||||
- by_service
|
||||
- by_business_scope
|
||||
- by_deal
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
description: The value or segment available for the selected dimension.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: billable_verifications
|
||||
data_type: bigint
|
||||
description: |
|
||||
The monthly billable verifications for a given date, dimension and value.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue