removed macro and kept all logic inside the model
This commit is contained in:
parent
78e2474a87
commit
ab179577b1
15 changed files with 52 additions and 53 deletions
|
|
@ -171,16 +171,13 @@ Provides a general assignement for the Dimensions available for each KPI
|
|||
] %}
|
||||
{% endif %}
|
||||
|
||||
{% if entity_name == "NEW_DASH" %}
|
||||
{% set additional_dimensions = additional_dimensions + [
|
||||
dim_has_upgraded_service(),
|
||||
dim_new_dash_version(),
|
||||
dim_pricing_service(),
|
||||
dim_pricing_business_type(),
|
||||
] %}
|
||||
{% endif %}
|
||||
|
||||
{% if entity_name == "NEW_DASH_DEALS_OFFERED_SERVICES" %}
|
||||
{% if entity_name in [
|
||||
"NEW_DASH_CREATED_SERVICES",
|
||||
"NEW_DASH_CHARGEABLE_SERVICES",
|
||||
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES",
|
||||
"NEW_DASH_CREATED_BOOKINGS",
|
||||
"NEW_DASH_DEALS_OFFERED_SERVICES",
|
||||
] %}
|
||||
{% set additional_dimensions = additional_dimensions + [
|
||||
dim_has_upgraded_service(),
|
||||
dim_new_dash_version(),
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
{% macro generate_kpis_aggregation(time_granularity, agg_models) %}
|
||||
select
|
||||
d.date,
|
||||
'{{ time_granularity }}' as time_granularity,
|
||||
d.dimension,
|
||||
d.dimension_value
|
||||
{%- for agg_model in agg_models if time_granularity in agg_model["name"] %}
|
||||
{%- for metric in agg_model["metrics"] %}
|
||||
, coalesce({{ ref(agg_model["name"]) }}.{{ metric }}, 0) as {{ metric }}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
from all_dates d
|
||||
{%- for agg_model in agg_models if time_granularity in agg_model["name"] %}
|
||||
left join
|
||||
{{ ref(agg_model["name"]) }}
|
||||
on d.date = {{ ref(agg_model["name"]) }}.{{ agg_model["date_field"] }}
|
||||
and d.dimension = {{ ref(agg_model["name"]) }}.dimension
|
||||
and d.dimension_value = {{ ref(agg_model["name"]) }}.dimension_value
|
||||
{%- endfor %}
|
||||
{% if time_granularity == "weekly" %} where d.is_end_of_week
|
||||
{% elif time_granularity == "monthly" %} where d.is_end_of_month
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model(
|
||||
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||
) %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CHARGEABLE_SERVICES") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_BOOKINGS") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_SERVICES") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model(
|
||||
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||
) %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CHARGEABLE_SERVICES") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_BOOKINGS") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_SERVICES") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model(
|
||||
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||
) %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CHARGEABLE_SERVICES") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_BOOKINGS") %}
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH") %}
|
||||
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_CREATED_SERVICES") %}
|
||||
|
||||
{{
|
||||
config(
|
||||
|
|
|
|||
|
|
@ -119,11 +119,30 @@ with
|
|||
left join int_kpis__dimension_dates d on c.date = d.date
|
||||
)
|
||||
|
||||
select *
|
||||
from ({{ generate_kpis_aggregation("daily", agg_models) }})
|
||||
union all
|
||||
select *
|
||||
from ({{ generate_kpis_aggregation("weekly", agg_models) }})
|
||||
union all
|
||||
select *
|
||||
from ({{ generate_kpis_aggregation("monthly", agg_models) }})
|
||||
{% for time_granularity in ["daily", "weekly", "monthly"] %}
|
||||
{% if time_granularity != "daily" %}
|
||||
union all
|
||||
{% endif %}
|
||||
|
||||
select
|
||||
d.date,
|
||||
'{{ time_granularity }}' as time_granularity,
|
||||
d.dimension,
|
||||
d.dimension_value
|
||||
{% for agg_model in agg_models if time_granularity in agg_model["name"] %}
|
||||
{% for metric in agg_model["metrics"] %}
|
||||
, coalesce({{ ref(agg_model["name"]) }}.{{ metric }}, 0) as {{ metric }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
from all_dates d
|
||||
{% for agg_model in agg_models if time_granularity in agg_model["name"] %}
|
||||
left join
|
||||
{{ ref(agg_model["name"]) }}
|
||||
on d.date = {{ ref(agg_model["name"]) }}.{{ agg_model["date_field"] }}
|
||||
and d.dimension = {{ ref(agg_model["name"]) }}.dimension
|
||||
and d.dimension_value = {{ ref(agg_model["name"]) }}.dimension_value
|
||||
{% endfor %}
|
||||
{% if time_granularity == "weekly" %} where d.is_end_of_week
|
||||
{% elif time_granularity == "monthly" %} where d.is_end_of_month
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue