Merged PR 2094: Removing lifecycle logic from int_core__accommodation

Removing lifecycle logic from int_core__accommodation
This logic is now available on int_core__mtd_accommodation_lifecycle

Related work items: #17312
This commit is contained in:
Oriol Roqué Paniagua 2024-06-21 14:13:42 +00:00
parent ef80637a9b
commit f23e210129
2 changed files with 5 additions and 229 deletions

View file

@ -502,32 +502,7 @@ models:
It contains information regarding the host this accommodation is linked to,
the geographic details, the preferred currency according to the country, details about
the listing itself (floors, bedrooms, etc) and time-related information of when the
listing was created, booked for the first time, last time, and second-to-last time.
The information regarding the booking-related time allows for the current status of
any listing regarding its activity. There's no history, it's just the most up-to-date
status of the listing activity. This information is encapsulated in the following columns:
accommodation_lifecycle_state: contains one of the following states
- 01-New: Listings that have been created in the current month, without bookings
- 02-Never Booked: Listings that have been created before the current month, without bookings.
- 03-First Time Booked: Listings that have been booked for the first time in the current month.
- 04-Active: Listings that have booking activity in the past 12 months (that are not FTB nor reactivated)
- 05-Churning: Listings that are becoming inactive because of lack of bookings in the past 12 months
- 06-Inactive: Listings that have not had a booking for more than 12 months.
- 07-Reactivated: Listings that have had a booking in the current month that were inactive or churning before.
- Finally, if none of the logic applies, which should not happen, null will be set and a dbt alert will raise.
Since the states of Active, First Time Booked and Reactivated indicate certain booking activity and are
mutually exclusive, the model also provides information of the recency of the bookings by the following
booleans:
- has_been_booked_in_1_month: If a listing has had a booking created in the current month
- has_been_booked_in_6_months: If a listing has had a booking created in the past 6 months
- has_been_booked_within_last_12_months: If a listing has had a booking created in the past 12 months
Note that if a listing has had a booking created this month, all 3 columns will be true. Similarly,
if the last booking created to a listing was 5 months ago, only the column has_been_booked_in_1_month
will be false; while the other 2 will be true.
listing was created.
columns:
- name: id_accommodation
@ -569,7 +544,8 @@ models:
Boolean to indicate if the listing is active or not. If false, this is considered as a
hard deactivation - meaning no more bookings can be assigned to this listing. However,
even if a listing is active, that does not necessarily mean that it's receiving bookings.
Do not confuse this column with the lifecycle activity of a listing.
Do not confuse this column with the lifecycle activity of a listing that is computed in
int_core__mtd_accommodation_lifecycle.
- name: town
data_type: character varying
@ -604,27 +580,6 @@ models:
- name: construction_details
data_type: character varying
- name: accommodation_lifecycle_state
data_type: character varying
description: |
Contains the lifecycle state of a Listing. The accepted values are:
01-New, 02-Never Booked, 03-First Time Booked, 04-Active, 05-Churning, 06-Inactive,
07-Reactivated. Failing to implement the logic will result in alert.
tests:
- not_null
- name: has_been_booked_within_current_month
data_type: boolean
description: If the listing has had a booking created in the current month.
- name: has_been_booked_within_last_6_months
data_type: boolean
description: If the listing has had a booking created in the past 6 months.
- name: has_been_booked_within_last_12_months
data_type: boolean
description: If the listing has had a booking created in the past 12 months.
- name: created_at_utc
data_type: timestamp
description: Timestamp of when the listing was created. Cannot be null.
@ -643,48 +598,6 @@ models:
data_type: date
description: Date of when the listing was last updated according to the backend.
- name: first_time_booked_at_utc
data_type: timestamp
description: |
Timestamp of the first booking created for a given listing. Can be null if the listing
has never had a booking associated with it.
- name: first_time_booked_date_utc
data_type: date
description: |
Date of the first booking created for a given listing. Can be null if the listing
has never had a booking associated with it.
- name: last_time_booked_at_utc
data_type: timestamp
description: |
Timestamp of the last booking created for a given listing. Can be null if the listing
has never had a booking associated with it. Can be the same as first_time_booked_at_utc
if the listing only had 1 booking in its history.
- name: last_time_booked_date_utc
data_type: date
description: |
Date of the last booking created for a given listing. Can be null if the listing
has never had a booking associated with it. Can be the same as first_time_booked_date_utc
if the listing only had 1 booking in its history.
- name: second_to_last_time_booked_at_utc
data_type: timestamp
description: |
Timestamp of the second-to-last booking created for a given listing, meaning the creation
time of the booking that precedes the last one. It's relevant for the reactivation computation
on the lifecycle. Can be null if the listing has never had a booking associated with it or if
the listing only had 1 booking in its history.
- name: second_to_last_time_booked_date_utc
data_type: date
description: |
Date of the second-to-last booking created for a given listing, meaning the creation
date of the booking that precedes the last one. It's relevant for the reactivation computation
on the lifecycle. Can be null if the listing has never had a booking associated with it or if
the listing only had 1 booking in its history.
- name: dwh_extracted_at_utc
data_type: timestamp
description: Timestamp of when the accommodation record was extracted from the backend into the DWH.