fixed model
This commit is contained in:
parent
0c5dd298ed
commit
aaf512a288
2 changed files with 21 additions and 38 deletions
|
|
@ -1,22 +1,16 @@
|
||||||
{% set sigma_threshold = var("sigma_threshold", 3) %}
|
with
|
||||||
{% set days_to_consider = 14 %}
|
stg_core__country as (select * from {{ ref("stg_core__country") }}),
|
||||||
{% set yesterday = "(current_date - interval '1 day')" %}
|
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||||
|
select
|
||||||
-- with
|
co.id_country,
|
||||||
-- stg_core__country as (select * from {{ ref("stg_core__country") }}),
|
co.iso_2,
|
||||||
-- stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
co.iso_3,
|
||||||
-- select
|
co.country_name,
|
||||||
-- co.id_country,
|
co.iso_num_code,
|
||||||
-- co.iso_2,
|
co.phone_code,
|
||||||
-- co.iso_3,
|
co.id_preferred_currency,
|
||||||
-- co.country_name,
|
cu.currency_name as preferred_currency_name,
|
||||||
-- co.iso_num_code,
|
cu.iso4217_code as preferred_iso4217_code,
|
||||||
-- co.phone_code,
|
co.dwh_extracted_at_utc
|
||||||
-- co.id_preferred_currency,
|
from stg_core__country as co
|
||||||
-- cu.currency_name as preferred_currency_name,
|
left join stg_core__currency cu on cu.id_currency = co.id_preferred_currency
|
||||||
-- cu.iso4217_code as preferred_iso4217_code,
|
|
||||||
-- co.dwh_extracted_at_utc
|
|
||||||
-- from stg_core__country as co
|
|
||||||
-- left join stg_core__currency cu on cu.id_currency = co.id_preferred_currency
|
|
||||||
|
|
||||||
select {{ yesterday }} - interval '{{ days_to_consider }} "days"'
|
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,6 @@ set number of days for all specified metrics
|
||||||
"waiver_payments_in_gbp",
|
"waiver_payments_in_gbp",
|
||||||
"checkin_cover_fees_in_gbp",
|
"checkin_cover_fees_in_gbp",
|
||||||
"total_guest_payments_in_gbp",
|
"total_guest_payments_in_gbp",
|
||||||
"py_created_guest_journeys_not_cancelled",
|
|
||||||
"py_started_guest_journeys_not_cancelled",
|
|
||||||
"py_completed_guest_journeys_not_cancelled",
|
|
||||||
"py_created_guest_journeys",
|
|
||||||
"py_started_guest_journeys",
|
|
||||||
"py_completed_guest_journeys",
|
|
||||||
"py_total_csat_score_count",
|
|
||||||
"py_average_csat_score",
|
|
||||||
"py_deposit_fees_in_gbp",
|
|
||||||
"py_waiver_payments_in_gbp",
|
|
||||||
"py_checkin_cover_fees_in_gbp",
|
|
||||||
"py_total_guest_payments_in_gbp",
|
|
||||||
) %}
|
) %}
|
||||||
-- Set the number of standard deviations (sigma) allowed
|
-- Set the number of standard deviations (sigma) allowed
|
||||||
-- for a value to be considered an outlier.
|
-- for a value to be considered an outlier.
|
||||||
|
|
@ -39,7 +27,6 @@ set number of days for all specified metrics
|
||||||
-- Set the number of previous days' data (e.g., 14 days) to
|
-- Set the number of previous days' data (e.g., 14 days) to
|
||||||
-- calculate the average and standard deviation for comparison.
|
-- calculate the average and standard deviation for comparison.
|
||||||
{% set days_to_consider = 14 %}
|
{% set days_to_consider = 14 %}
|
||||||
{% set yesterday = "(current_date - interval '1 day')" %}
|
|
||||||
|
|
||||||
with
|
with
|
||||||
recent_data as (
|
recent_data as (
|
||||||
|
|
@ -47,8 +34,10 @@ with
|
||||||
from {{ ref("kpis__product_guest_daily_metrics") }}
|
from {{ ref("kpis__product_guest_daily_metrics") }}
|
||||||
where
|
where
|
||||||
date_day
|
date_day
|
||||||
between {{ yesterday }}
|
between (current_date - interval '{{ days_to_consider + 1 }} days') and (
|
||||||
- interval '{{ days_to_consider }} "days"' and {{ yesterday }}
|
current_date - interval '1 day'
|
||||||
|
)
|
||||||
|
|
||||||
),
|
),
|
||||||
metrics_recent_data as (
|
metrics_recent_data as (
|
||||||
select
|
select
|
||||||
|
|
@ -76,7 +65,7 @@ with
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
from recent_data rd
|
from recent_data rd
|
||||||
cross join metrics_recent_data
|
cross join metrics_recent_data
|
||||||
where rd.date_day = {{ yesterday }}
|
where rd.date_day = current_date - interval '1 day'
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
{% for metric in metric_names %}
|
{% for metric in metric_names %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue