mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
Redefined on-time logic
This commit is contained in:
@@ -190,9 +190,15 @@ fct_and_dim_joins AS (
|
||||
CASE
|
||||
{% for (service_type, working_day) in service_type_work_day_dict.items() %}
|
||||
|
||||
WHEN orders.order_created_datetime >= '2023-01-01' AND orders.service_type = '{{service_type}}' AND DATE_PART(HOUR, orders.order_pending_verification_datetime) < 16
|
||||
WHEN
|
||||
orders.order_created_datetime >= '2023-01-01' AND orders.service_type = '{{service_type}}'
|
||||
AND
|
||||
DATE_PART(HOUR, orders.order_pending_verification_datetime) < 16
|
||||
THEN TO_TIMESTAMP(order_created_dates.{{working_day['include_base']}} || ' ' || (orders.order_pending_verification_datetime::TIME)::STRING )
|
||||
WHEN orders.order_created_datetime >= '2023-01-01' AND orders.service_type = '{{service_type}}' AND DATE_PART(HOUR, orders.order_pending_verification_datetime) >= 16
|
||||
WHEN
|
||||
orders.order_created_datetime >= '2023-01-01'
|
||||
AND
|
||||
orders.service_type = '{{service_type}}' AND DATE_PART(HOUR, orders.order_pending_verification_datetime) >= 16
|
||||
THEN TO_TIMESTAMP(order_created_dates.{{working_day['exclude_base']}} || ' ' || (orders.order_pending_verification_datetime::TIME)::STRING )
|
||||
|
||||
{% endfor %}
|
||||
@@ -203,19 +209,21 @@ fct_and_dim_joins AS (
|
||||
-- On time delivery boolean (CIEF internal SLA)
|
||||
CASE
|
||||
-- On-time boolean is null when order is not complete
|
||||
WHEN account_verified_payment_datetime IS NULL THEN NULL
|
||||
WHEN estimated_order_delivery_datetime_website_sla IS NULL THEN NULL
|
||||
WHEN service_type IN ('BA') THEN NULL
|
||||
WHEN transaction_status NOT IN ('UPLOADED_BANK_SLIP') THEN NULL
|
||||
WHEN estimated_order_delivery_datetime_website_sla > orders.operation_uploaded_bank_slip_datetime THEN 1
|
||||
ELSE 0
|
||||
WHEN estimated_order_delivery_datetime_website_sla < orders.operation_uploaded_bank_slip_datetime THEN 0
|
||||
ELSE -999
|
||||
END AS is_on_time_delivery_website_sla,
|
||||
|
||||
-- On time delivery boolean (Customer Expectation)
|
||||
CASE
|
||||
-- On-time boolean is null when order is not complete
|
||||
WHEN account_verified_payment_datetime IS NULL THEN NULL
|
||||
WHEN estimated_order_delivery_datetime_customer_expectation IS NULL THEN NULL
|
||||
WHEN service_type IN ('BA') THEN NULL
|
||||
WHEN transaction_status NOT IN ('UPLOADED_BANK_SLIP') THEN NULL
|
||||
WHEN estimated_order_delivery_datetime_customer_expectation > orders.operation_uploaded_bank_slip_datetime THEN 1
|
||||
ELSE 0
|
||||
WHEN estimated_order_delivery_datetime_customer_expectation < orders.operation_uploaded_bank_slip_datetime THEN 0
|
||||
ELSE -999
|
||||
END AS is_on_time_delivery_customer_expectation,
|
||||
|
||||
'{{ modules.datetime.datetime.now(modules.pytz.timezone("Asia/Kuala_Lumpur")) }}' AS _dbt_ran_datetime
|
||||
@@ -242,6 +250,7 @@ fct_and_dim_joins AS (
|
||||
|
||||
),
|
||||
|
||||
|
||||
--FINAL
|
||||
final__rep_exchange__daily_orders AS (
|
||||
|
||||
|
||||
Reference in New Issue
Block a user