From 3f3b99cdf6bbc6f8e0f111a05ac1dcbc4a735cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADn?= Date: Fri, 17 Jan 2025 16:34:29 +0000 Subject: [PATCH] Merged PR 4102: Athena price update # Description This PR handles the new price set for Athena in Nov.24, as indicated by Nila from Finance (see more detailes in linked story). Price has gone from 2.0GBP to 2.1GBP. Note that I have manually checked the correctness of the figures, I'm highly confident on the quality of the PR. All figures stay the same in old and new version of to the cutoff date (`2024-11-01T00:00:00Z`). Then, after that date, the 10 cents extra show appropiately. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #26475 --- .../int_athena__verifications_with_fees.sql | 12 ++++++---- seeds/schema.yml | 22 +++++++++++++++++++ seeds/stg_seed__athena_price_history.csv | 3 +++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 seeds/stg_seed__athena_price_history.csv diff --git a/models/intermediate/athena/int_athena__verifications_with_fees.sql b/models/intermediate/athena/int_athena__verifications_with_fees.sql index 0f63f91..707c3b1 100644 --- a/models/intermediate/athena/int_athena__verifications_with_fees.sql +++ b/models/intermediate/athena/int_athena__verifications_with_fees.sql @@ -1,8 +1,9 @@ {% set ok_status = "Approved" %} --- 2GBP/booked night if booking is approved, to be charged on checkout -{% set cost_per_night = 2 %} with int_athena__verifications as (select * from {{ ref("int_athena__verifications") }}), + stg_seed__athena_price_history as ( + select * from {{ ref("stg_seed__athena_price_history") }} + ), -- CTE to rank verifications by updated_at_utc per id_booking ranked_verifications as ( select @@ -21,14 +22,17 @@ select -- Charge for 1 night if number_nights = 0 case when v.number_nights = 0 and v.verification_status = '{{ ok_status }}' - then {{ cost_per_night }} + then ph.fee_per_night_gbp when v.verification_status = '{{ ok_status }}' - then v.number_nights * {{ cost_per_night }} + then v.number_nights * ph.fee_per_night_gbp else 0 end as ok_status_fee_in_gbp, v.created_date_utc, v.checkout_date_utc from ranked_verifications v +left join + stg_seed__athena_price_history ph + on v.checkout_date_utc between ph.start_at_utc and ph.end_at_utc where -- Select only the most recent verification for each id_booking v.rn = 1 diff --git a/seeds/schema.yml b/seeds/schema.yml index 646ddd8..db9d86d 100644 --- a/seeds/schema.yml +++ b/seeds/schema.yml @@ -152,3 +152,25 @@ seeds: description: | How much Superhog decided to pay out to the partner as part of this claim, defined in the settlement currency. + + - name: stg_seed__athena_price_history + description: | + A price history for the Athena fee per night. + + Yes, I know. It's terrible that we keep this here. Oh boy, how I wish it + wasn't like this! + + columns: + - name: start_at_utc + data_type: timestamp + description: | + The start of the time range where this record is applicable. + + - name: end_at_utc + data_type: timestamp + description: The end of the time range where this record is applicable. + + - name: fee_per_night_gbp + data_type: numeric + description: | + How much we charge per night in this time range. diff --git a/seeds/stg_seed__athena_price_history.csv b/seeds/stg_seed__athena_price_history.csv new file mode 100644 index 0000000..58b92c2 --- /dev/null +++ b/seeds/stg_seed__athena_price_history.csv @@ -0,0 +1,3 @@ +start_at_utc,end_at_utc,fee_per_night_gbp +2020-01-01T00:00:00Z,2024-11-01T00:00:00Z,2.0 +2024-11-01T00:00:00Z,2099-12-31T00:00:00Z,2.1 \ No newline at end of file