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) %}
|
||||
{% set days_to_consider = 14 %}
|
||||
{% set yesterday = "(current_date - interval '1 day')" %}
|
||||
|
||||
-- with
|
||||
-- stg_core__country as (select * from {{ ref("stg_core__country") }}),
|
||||
-- stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||
-- select
|
||||
-- co.id_country,
|
||||
-- co.iso_2,
|
||||
-- co.iso_3,
|
||||
-- co.country_name,
|
||||
-- co.iso_num_code,
|
||||
-- co.phone_code,
|
||||
-- co.id_preferred_currency,
|
||||
-- cu.currency_name as preferred_currency_name,
|
||||
-- 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"'
|
||||
with
|
||||
stg_core__country as (select * from {{ ref("stg_core__country") }}),
|
||||
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||
select
|
||||
co.id_country,
|
||||
co.iso_2,
|
||||
co.iso_3,
|
||||
co.country_name,
|
||||
co.iso_num_code,
|
||||
co.phone_code,
|
||||
co.id_preferred_currency,
|
||||
cu.currency_name as preferred_currency_name,
|
||||
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
|
||||
|
|
|
|||
|
|
@ -18,18 +18,6 @@ set number of days for all specified metrics
|
|||
"waiver_payments_in_gbp",
|
||||
"checkin_cover_fees_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
|
||||
-- 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
|
||||
-- calculate the average and standard deviation for comparison.
|
||||
{% set days_to_consider = 14 %}
|
||||
{% set yesterday = "(current_date - interval '1 day')" %}
|
||||
|
||||
with
|
||||
recent_data as (
|
||||
|
|
@ -47,8 +34,10 @@ with
|
|||
from {{ ref("kpis__product_guest_daily_metrics") }}
|
||||
where
|
||||
date_day
|
||||
between {{ yesterday }}
|
||||
- interval '{{ days_to_consider }} "days"' and {{ yesterday }}
|
||||
between (current_date - interval '{{ days_to_consider + 1 }} days') and (
|
||||
current_date - interval '1 day'
|
||||
)
|
||||
|
||||
),
|
||||
metrics_recent_data as (
|
||||
select
|
||||
|
|
@ -76,7 +65,7 @@ with
|
|||
{% endfor %}
|
||||
from recent_data rd
|
||||
cross join metrics_recent_data
|
||||
where rd.date_day = {{ yesterday }}
|
||||
where rd.date_day = current_date - interval '1 day'
|
||||
)
|
||||
select
|
||||
{% for metric in metric_names %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue