|
|
|
|
@ -1,208 +1,129 @@
|
|
|
|
|
{% set agg_models = [
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_daily_new_dash_created_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["created_services"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_daily_new_dash_chargeable_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": [
|
|
|
|
|
"total_chargeable_services",
|
|
|
|
|
"total_chargeable_amount_in_gbp",
|
|
|
|
|
"unique_chargeable_bookings",
|
|
|
|
|
"unique_chargeable_listings",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_daily_new_dash_deals_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["deal_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_daily_new_dash_accommodation_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["accommodation_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_daily_new_dash_created_bookings",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["created_bookings"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_weekly_new_dash_created_services",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": ["created_services"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_weekly_new_dash_chargeable_services",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": [
|
|
|
|
|
"total_chargeable_services",
|
|
|
|
|
"total_chargeable_amount_in_gbp",
|
|
|
|
|
"unique_chargeable_bookings",
|
|
|
|
|
"unique_chargeable_listings",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_weekly_new_dash_deals_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["deal_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_weekly_new_dash_accommodation_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["accommodation_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_weekly_new_dash_created_bookings",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": ["created_bookings"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_monthly_new_dash_created_services",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": ["created_services"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_monthly_new_dash_chargeable_services",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": [
|
|
|
|
|
"total_chargeable_services",
|
|
|
|
|
"total_chargeable_amount_in_gbp",
|
|
|
|
|
"unique_chargeable_bookings",
|
|
|
|
|
"unique_chargeable_listings",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_monthly_new_dash_deals_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["deal_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_monthly_new_dash_accommodation_offered_services",
|
|
|
|
|
"date_field": "date",
|
|
|
|
|
"metrics": ["accommodation_with_offered_service_count"],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "int_kpis__agg_monthly_new_dash_created_bookings",
|
|
|
|
|
"date_field": "end_date",
|
|
|
|
|
"metrics": ["created_bookings"],
|
|
|
|
|
},
|
|
|
|
|
] %}
|
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
int_kpis__agg_daily_new_dash_created_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_daily_new_dash_created_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_weekly_new_dash_created_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_weekly_new_dash_created_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_monthly_new_dash_created_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_monthly_new_dash_created_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_daily_new_dash_chargeable_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_daily_new_dash_chargeable_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_weekly_new_dash_chargeable_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_weekly_new_dash_chargeable_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_monthly_new_dash_chargeable_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_monthly_new_dash_chargeable_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_daily_new_dash_deals_offered_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_daily_new_dash_deals_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_weekly_new_dash_deals_offered_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_weekly_new_dash_deals_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_monthly_new_dash_deals_offered_services as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_monthly_new_dash_deals_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_daily_new_dash_accommodation_offered_services as (
|
|
|
|
|
select *
|
|
|
|
|
from {{ ref("int_kpis__agg_daily_new_dash_accommodation_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_weekly_new_dash_accommodation_offered_services as (
|
|
|
|
|
select *
|
|
|
|
|
from {{ ref("int_kpis__agg_weekly_new_dash_accommodation_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_monthly_new_dash_accommodation_offered_services as (
|
|
|
|
|
select *
|
|
|
|
|
from {{ ref("int_kpis__agg_monthly_new_dash_accommodation_offered_services") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_daily_new_dash_created_bookings as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_daily_new_dash_created_bookings") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_weekly_new_dash_created_bookings as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_weekly_new_dash_created_bookings") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__agg_monthly_new_dash_created_bookings as (
|
|
|
|
|
select * from {{ ref("int_kpis__agg_monthly_new_dash_created_bookings") }}
|
|
|
|
|
),
|
|
|
|
|
int_kpis__dimension_dates as (select * from {{ ref("int_kpis__dimension_dates") }}),
|
|
|
|
|
|
|
|
|
|
all_dates as (
|
|
|
|
|
select distinct
|
|
|
|
|
c.date, c.dimension, c.dimension_value, d.is_end_of_week, d.is_end_of_month
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select date, dimension, dimension_value
|
|
|
|
|
from int_kpis__agg_daily_new_dash_created_services
|
|
|
|
|
from {{ ref("int_kpis__agg_daily_new_dash_created_services") }}
|
|
|
|
|
union all
|
|
|
|
|
select date, dimension, dimension_value
|
|
|
|
|
from int_kpis__agg_daily_new_dash_chargeable_services
|
|
|
|
|
from {{ ref("int_kpis__agg_daily_new_dash_chargeable_services") }}
|
|
|
|
|
union all
|
|
|
|
|
select date, dimension, dimension_value
|
|
|
|
|
from int_kpis__agg_daily_new_dash_deals_offered_services
|
|
|
|
|
from {{ ref("int_kpis__agg_daily_new_dash_deals_offered_services") }}
|
|
|
|
|
union all
|
|
|
|
|
select date, dimension, dimension_value
|
|
|
|
|
from int_kpis__agg_daily_new_dash_accommodation_offered_services
|
|
|
|
|
from
|
|
|
|
|
{{
|
|
|
|
|
ref(
|
|
|
|
|
"int_kpis__agg_daily_new_dash_accommodation_offered_services"
|
|
|
|
|
)
|
|
|
|
|
}}
|
|
|
|
|
) c
|
|
|
|
|
left join int_kpis__dimension_dates d on c.date = d.date
|
|
|
|
|
)
|
|
|
|
|
select
|
|
|
|
|
d.date,
|
|
|
|
|
'daily' as time_granularity,
|
|
|
|
|
d.dimension,
|
|
|
|
|
d.dimension_value,
|
|
|
|
|
coalesce(
|
|
|
|
|
deals.deal_with_offered_service_count, 0
|
|
|
|
|
) as deal_with_offered_service_count,
|
|
|
|
|
coalesce(
|
|
|
|
|
accommodation.accommodation_with_offered_service_count, 0
|
|
|
|
|
) as accommodation_with_offered_service_count,
|
|
|
|
|
coalesce(created.created_services, 0) as created_services,
|
|
|
|
|
coalesce(bookings.created_bookings, 0) as created_bookings_count,
|
|
|
|
|
coalesce(chargeable.total_chargeable_services, 0) as total_chargeable_services,
|
|
|
|
|
coalesce(
|
|
|
|
|
chargeable.total_chargeable_amount_in_gbp, 0
|
|
|
|
|
) as total_chargeable_amount_in_gbp,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_bookings, 0) as unique_chargeable_bookings,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_listings, 0) as unique_chargeable_listings
|
|
|
|
|
from all_dates d
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_daily_new_dash_created_services created
|
|
|
|
|
on d.date = created.date
|
|
|
|
|
and d.dimension = created.dimension
|
|
|
|
|
and d.dimension_value = created.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_daily_new_dash_chargeable_services chargeable
|
|
|
|
|
on d.date = chargeable.date
|
|
|
|
|
and d.dimension = chargeable.dimension
|
|
|
|
|
and d.dimension_value = chargeable.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_daily_new_dash_deals_offered_services deals
|
|
|
|
|
on d.date = deals.date
|
|
|
|
|
and d.dimension = deals.dimension
|
|
|
|
|
and d.dimension_value = deals.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_daily_new_dash_accommodation_offered_services accommodation
|
|
|
|
|
on d.date = accommodation.date
|
|
|
|
|
and d.dimension = accommodation.dimension
|
|
|
|
|
and d.dimension_value = accommodation.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_daily_new_dash_created_bookings bookings
|
|
|
|
|
on d.date = bookings.date
|
|
|
|
|
and d.dimension = bookings.dimension
|
|
|
|
|
and d.dimension_value = bookings.dimension_value
|
|
|
|
|
|
|
|
|
|
select *
|
|
|
|
|
from ({{ generate_kpis_aggregation("daily", agg_models) }})
|
|
|
|
|
union all
|
|
|
|
|
select
|
|
|
|
|
d.date,
|
|
|
|
|
'weekly' as time_granularity,
|
|
|
|
|
d.dimension,
|
|
|
|
|
d.dimension_value,
|
|
|
|
|
coalesce(
|
|
|
|
|
deals.deal_with_offered_service_count, 0
|
|
|
|
|
) as deal_with_offered_service_count,
|
|
|
|
|
coalesce(
|
|
|
|
|
accommodation.accommodation_with_offered_service_count, 0
|
|
|
|
|
) as accommodation_with_offered_service_count,
|
|
|
|
|
coalesce(created.created_services, 0) as created_services,
|
|
|
|
|
coalesce(bookings.created_bookings, 0) as created_bookings_count,
|
|
|
|
|
coalesce(chargeable.total_chargeable_services, 0) as total_chargeable_services,
|
|
|
|
|
coalesce(
|
|
|
|
|
chargeable.total_chargeable_amount_in_gbp, 0
|
|
|
|
|
) as total_chargeable_amount_in_gbp,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_bookings, 0) as unique_chargeable_bookings,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_listings, 0) as unique_chargeable_listings
|
|
|
|
|
from all_dates d
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_weekly_new_dash_created_services created
|
|
|
|
|
on d.date = created.end_date
|
|
|
|
|
and d.dimension = created.dimension
|
|
|
|
|
and d.dimension_value = created.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_weekly_new_dash_chargeable_services chargeable
|
|
|
|
|
on d.date = chargeable.end_date
|
|
|
|
|
and d.dimension = chargeable.dimension
|
|
|
|
|
and d.dimension_value = chargeable.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_weekly_new_dash_deals_offered_services deals
|
|
|
|
|
on d.date = deals.date
|
|
|
|
|
and d.dimension = deals.dimension
|
|
|
|
|
and d.dimension_value = deals.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_weekly_new_dash_accommodation_offered_services accommodation
|
|
|
|
|
on d.date = accommodation.date
|
|
|
|
|
and d.dimension = accommodation.dimension
|
|
|
|
|
and d.dimension_value = accommodation.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_weekly_new_dash_created_bookings bookings
|
|
|
|
|
on d.date = bookings.end_date
|
|
|
|
|
and d.dimension = bookings.dimension
|
|
|
|
|
and d.dimension_value = bookings.dimension_value
|
|
|
|
|
where d.is_end_of_week
|
|
|
|
|
select *
|
|
|
|
|
from ({{ generate_kpis_aggregation("weekly", agg_models) }})
|
|
|
|
|
union all
|
|
|
|
|
select
|
|
|
|
|
d.date,
|
|
|
|
|
'monthly' as time_granularity,
|
|
|
|
|
d.dimension,
|
|
|
|
|
d.dimension_value,
|
|
|
|
|
coalesce(
|
|
|
|
|
deals.deal_with_offered_service_count, 0
|
|
|
|
|
) as deal_with_offered_service_count,
|
|
|
|
|
coalesce(
|
|
|
|
|
accommodation.accommodation_with_offered_service_count, 0
|
|
|
|
|
) as accommodation_with_offered_service_count,
|
|
|
|
|
coalesce(created.created_services, 0) as created_services,
|
|
|
|
|
coalesce(bookings.created_bookings, 0) as created_bookings_count,
|
|
|
|
|
coalesce(chargeable.total_chargeable_services, 0) as total_chargeable_services,
|
|
|
|
|
coalesce(
|
|
|
|
|
chargeable.total_chargeable_amount_in_gbp, 0
|
|
|
|
|
) as total_chargeable_amount_in_gbp,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_bookings, 0) as unique_chargeable_bookings,
|
|
|
|
|
coalesce(chargeable.unique_chargeable_listings, 0) as unique_chargeable_listings
|
|
|
|
|
from all_dates d
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_monthly_new_dash_created_services created
|
|
|
|
|
on d.date = created.end_date
|
|
|
|
|
and d.dimension = created.dimension
|
|
|
|
|
and d.dimension_value = created.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_monthly_new_dash_chargeable_services chargeable
|
|
|
|
|
on d.date = chargeable.end_date
|
|
|
|
|
and d.dimension = chargeable.dimension
|
|
|
|
|
and d.dimension_value = chargeable.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_monthly_new_dash_deals_offered_services deals
|
|
|
|
|
on d.date = deals.date
|
|
|
|
|
and d.dimension = deals.dimension
|
|
|
|
|
and d.dimension_value = deals.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_monthly_new_dash_accommodation_offered_services accommodation
|
|
|
|
|
on d.date = accommodation.date
|
|
|
|
|
and d.dimension = accommodation.dimension
|
|
|
|
|
and d.dimension_value = accommodation.dimension_value
|
|
|
|
|
left join
|
|
|
|
|
int_kpis__agg_monthly_new_dash_created_bookings bookings
|
|
|
|
|
on d.date = bookings.end_date
|
|
|
|
|
and d.dimension = bookings.dimension
|
|
|
|
|
and d.dimension_value = bookings.dimension_value
|
|
|
|
|
where d.is_end_of_month
|
|
|
|
|
select *
|
|
|
|
|
from ({{ generate_kpis_aggregation("monthly", agg_models) }})
|
|
|
|
|
|