Listings report model

This commit is contained in:
Joaquin Ossa 2025-02-03 10:37:25 +01:00
parent 353972984e
commit 3b6f6eed0a
4 changed files with 314 additions and 0 deletions

View file

@ -0,0 +1,51 @@
with
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }}),
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
int_core__user_host as (select * from {{ ref("int_core__user_host") }})
select
a.id_accommodation,
a.id_user_host,
uh.id_deal,
uh.company_name,
uh.email,
uh.first_name,
uh.last_name,
a.is_active,
a.friendly_name,
a.country_name,
a.town,
a.address_line_1,
a.address_line_2,
a.country_iso_2,
a.postcode,
a.country_preferred_currency_code as currency_iso4217,
a.created_date_utc,
sum(
case when upper(b.booking_state) = 'APPROVED' then 1 else 0 end
) as approved_bookings,
sum(
case when upper(b.booking_state) = 'CANCELLED' then 1 else 0 end
) as cancelled_bookings,
sum(
case when upper(b.booking_state) = 'FLAGGED' then 1 else 0 end
) as flagged_bookings,
sum(
case when upper(b.booking_state) = 'INCOMPLETEINFORMATION' then 1 else 0 end
) as incomplete_information_bookings,
sum(
case when upper(b.booking_state) = 'NOFLAGS' then 1 else 0 end
) as no_flags_bookings,
sum(
case when upper(b.booking_state) = 'NOTAPPROVED' then 1 else 0 end
) as not_approved_bookings,
sum(
case when upper(b.booking_state) = 'REJECTED' then 1 else 0 end
) as rejected_bookings,
count(b.id_booking) as total_bookings
from int_core__accommodation a
left join int_core__user_host uh on a.id_user_host = uh.id_user_host
left join
int_core__bookings b
on a.id_accommodation = b.id_accommodation
and b.is_duplicate_booking = false
group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17

View file

@ -4866,3 +4866,119 @@ models:
Date of when this user was last updated.
data_tests:
- not_null
- name: int_core__accommodations_activity
description: |
This model provides a detailed information on listings, including their hosts,
and related booking activity. It contains identifiers, geographic information,
host details, and booking counts categorized by status.
columns:
- name: id_accommodation
data_type: bigint
description: "The unique identifier of the listing."
data_tests:
- unique
- not_null
- name: id_user_host
data_type: text
description: "The unique identifier of the host associated with the listing."
- name: id_deal
data_type: character varying
description: |
The primary identifier of the B2B client (deal). A deal can be linked to multiple hosts,
while a host can have at most one deal or none. This field can be null if there is no deal.
- name: company_name
data_type: character varying
description: |
The name of the company associated with the host. This value may sometimes match
the host's first name, last name, a combination of both, or be entirely different.
It can also be null or empty.
- name: email
data_type: character varying
description: "The email address of the host."
- name: first_name
data_type: character varying
description: "The first name of the host."
- name: last_name
data_type: character varying
description: "The last name of the host."
- name: is_active
data_type: boolean
description: |
Indicates whether the listing is currently active.
- name: friendly_name
data_type: character varying
description: "A user-friendly name assigned to the listing."
- name: country_name
data_type: character varying
description: "The full name of the country where the listing is located."
- name: town
data_type: character varying
description: "The town or city where the listing is located."
- name: address_line_1
data_type: character varying
description: "The first line of the listing's address."
- name: address_line_2
data_type: character varying
description: "The second line of the listing's address, if applicable."
- name: country_iso_2
data_type: character varying
description: "The two-letter ISO 3166-1 country code representing the listing's country."
- name: postcode
data_type: character varying
description: "The postal code of the listing's location."
- name: currency_iso4217
data_type: character varying
description: "The three-letter ISO 4217 currency code for transactions related to the listing."
- name: created_date_utc
data_type: date
description: "The date when the listing was first created."
- name: approved_bookings
data_type: bigint
description: "The total number of bookings with status approved for this accommodation."
- name: cancelled_bookings
data_type: bigint
description: "The total number of bookings with status cancelled for this accommodation."
- name: flagged_bookings
data_type: bigint
description: "The total number of bookings with status flagged for this accommodation."
- name: incomplete_information_bookings
data_type: bigint
description: "The total number of bookings with status incomplete information for this accommodation."
- name: no_flags_bookings
data_type: bigint
description: "The total number of bookings with status no flags for this accommodation."
- name: not_approved_bookings
data_type: bigint
description: "The total number of bookings with status not approved for this accommodation."
- name: rejected_bookings
data_type: bigint
description: "The total number of bookings with status rejected for this accommodation."
- name: total_bookings
data_type: bigint
description: "The total number of bookings for this accommodation."

View file

@ -0,0 +1,31 @@
with
int_core__accommodations_activity as (
select * from {{ ref("int_core__accommodations_activity") }}
)
select
id_accommodation as id_accommodation,
id_user_host as id_user_host,
id_deal as id_deal,
company_name as company_name,
email as email,
first_name as first_name,
last_name as last_name,
is_active as is_active,
friendly_name as friendly_name,
country_name as country_name,
town as town,
address_line_1 as address_line_1,
address_line_2 as address_line_2,
country_iso_2 as country_iso_2,
postcode as postcode,
currency_iso4217 as currency_iso4217,
created_date_utc as created_date_utc,
approved_bookings as approved_bookings,
cancelled_bookings as cancelled_bookings,
flagged_bookings as flagged_bookings,
incomplete_information_bookings as incomplete_information_bookings,
no_flags_bookings as no_flags_bookings,
not_approved_bookings as not_approved_bookings,
rejected_bookings as rejected_bookings,
total_bookings as total_bookings
from int_core__accommodations_activity

View file

@ -1268,3 +1268,119 @@ models:
data_type: integer
description: |
Integer-based flag version of total_bookings_with_product_bundle_with_paid_service.
- name: core__accommodations_activity
description: |
This model provides a detailed information on listings, including their hosts,
and related booking activity. It contains identifiers, geographic information,
host details, and booking counts categorized by status.
columns:
- name: id_accommodation
data_type: bigint
description: "The unique identifier of the listing."
data_tests:
- unique
- not_null
- name: id_user_host
data_type: text
description: "The unique identifier of the host associated with the listing."
- name: id_deal
data_type: character varying
description: |
The primary identifier of the B2B client (deal). A deal can be linked to multiple hosts,
while a host can have at most one deal or none. This field can be null if there is no deal.
- name: company_name
data_type: character varying
description: |
The name of the company associated with the host. This value may sometimes match
the host's first name, last name, a combination of both, or be entirely different.
It can also be null or empty.
- name: email
data_type: character varying
description: "The email address of the host."
- name: first_name
data_type: character varying
description: "The first name of the host."
- name: last_name
data_type: character varying
description: "The last name of the host."
- name: is_active
data_type: boolean
description: |
Indicates whether the listing is currently active.
- name: friendly_name
data_type: character varying
description: "A user-friendly name assigned to the listing."
- name: country_name
data_type: character varying
description: "The full name of the country where the listing is located."
- name: town
data_type: character varying
description: "The town or city where the listing is located."
- name: address_line_1
data_type: character varying
description: "The first line of the listing's address."
- name: address_line_2
data_type: character varying
description: "The second line of the listing's address, if applicable."
- name: country_iso_2
data_type: character varying
description: "The two-letter ISO 3166-1 country code representing the listing's country."
- name: postcode
data_type: character varying
description: "The postal code of the listing's location."
- name: currency_iso4217
data_type: character varying
description: "The three-letter ISO 4217 currency code for transactions related to the listing."
- name: created_date_utc
data_type: date
description: "The date when the listing was first created."
- name: approved_bookings
data_type: bigint
description: "The total number of bookings with status approved for this accommodation."
- name: cancelled_bookings
data_type: bigint
description: "The total number of bookings with status cancelled for this accommodation."
- name: flagged_bookings
data_type: bigint
description: "The total number of bookings with status flagged for this accommodation."
- name: incomplete_information_bookings
data_type: bigint
description: "The total number of bookings with status incomplete information for this accommodation."
- name: no_flags_bookings
data_type: bigint
description: "The total number of bookings with status no flags for this accommodation."
- name: not_approved_bookings
data_type: bigint
description: "The total number of bookings with status not approved for this accommodation."
- name: rejected_bookings
data_type: bigint
description: "The total number of bookings with status rejected for this accommodation."
- name: total_bookings
data_type: bigint
description: "The total number of bookings for this accommodation."