fixed model

This commit is contained in:
Joaquin Ossa 2024-11-25 10:11:05 +01:00
parent 0c5dd298ed
commit aaf512a288
2 changed files with 21 additions and 38 deletions

View file

@ -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 %}