Merged PR 2662: New Dash MVP - with. fix on production issue
# Description Same PR as before, just adds a new commit that fixes my silly issue in prod. I owe some drinks :D # 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: #19570
This commit is contained in:
parent
f6f4ca83b7
commit
2facaceec0
4 changed files with 392 additions and 2 deletions
108
models/intermediate/core/int_core__new_dash_user_overview.sql
Normal file
108
models/intermediate/core/int_core__new_dash_user_overview.sql
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{% set product_bundles_without_paid_service = "('BasicScreening')" %}
|
||||
with
|
||||
int_core__user_product_bundle as (
|
||||
select * from {{ ref("int_core__user_product_bundle") }}
|
||||
),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
|
||||
int_core__booking_to_product_bundle as (
|
||||
select * from {{ ref("int_core__booking_to_product_bundle") }}
|
||||
),
|
||||
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }}),
|
||||
int_core__accommodation_to_product_bundle as (
|
||||
select * from {{ ref("int_core__accommodation_to_product_bundle") }}
|
||||
),
|
||||
|
||||
user_aggregation as (
|
||||
|
||||
select
|
||||
upb.id_user_host,
|
||||
uh.migration_phase as user_migration_phase,
|
||||
uh.lower_limit_migration_date_utc as user_estimated_migration_date_utc,
|
||||
uh.company_name,
|
||||
uh.first_name,
|
||||
uh.last_name,
|
||||
uh.account_currency_iso4217 as account_currency,
|
||||
count(distinct upb.id_user_product_bundle) as total_user_product_bundles,
|
||||
count(
|
||||
distinct case
|
||||
when upb.has_no_end_date then upb.id_user_product_bundle else null
|
||||
end
|
||||
) as total_active_user_product_bundles,
|
||||
count(distinct a.id_accommodation) as total_listings,
|
||||
count(
|
||||
distinct case
|
||||
when a.is_active = true then a.id_accommodation else null
|
||||
end
|
||||
) as total_active_listings,
|
||||
count(
|
||||
distinct case
|
||||
when
|
||||
atpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
then atpb.id_accommodation
|
||||
else null
|
||||
end
|
||||
) as total_listings_with_product_bundle_with_paid_service,
|
||||
count(
|
||||
distinct case
|
||||
when
|
||||
atpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
and atpb.has_no_end_date = true
|
||||
then atpb.id_accommodation
|
||||
else null
|
||||
end
|
||||
) as total_listings_with_active_product_bundle_with_paid_service,
|
||||
count(distinct btpb.id_booking) as total_bookings_with_product_bundle,
|
||||
count(
|
||||
distinct case
|
||||
when
|
||||
btpb.user_product_bundle_name
|
||||
not in {{ product_bundles_without_paid_service }}
|
||||
then btpb.id_booking
|
||||
else null
|
||||
end
|
||||
) as total_bookings_with_product_bundle_with_paid_service
|
||||
from int_core__user_product_bundle upb
|
||||
inner join int_core__user_host uh on upb.id_user_host = uh.id_user_host
|
||||
left join
|
||||
int_core__booking_to_product_bundle btpb
|
||||
on upb.id_user_product_bundle = btpb.id_user_product_bundle
|
||||
left join int_core__accommodation a on upb.id_user_host = a.id_user_host
|
||||
left join
|
||||
int_core__accommodation_to_product_bundle atpb
|
||||
on upb.id_user_product_bundle = atpb.id_user_product_bundle
|
||||
group by 1, 2, 3, 4, 5, 6, 7
|
||||
|
||||
)
|
||||
select
|
||||
id_user_host,
|
||||
user_migration_phase,
|
||||
user_estimated_migration_date_utc,
|
||||
company_name,
|
||||
first_name,
|
||||
last_name,
|
||||
account_currency,
|
||||
total_user_product_bundles,
|
||||
total_active_user_product_bundles,
|
||||
total_listings,
|
||||
total_active_listings,
|
||||
total_listings_with_product_bundle_with_paid_service,
|
||||
case when total_active_listings > 0 then 1 else 0 end as has_active_listings,
|
||||
case
|
||||
when total_listings_with_product_bundle_with_paid_service > 0 then 1 else 0
|
||||
end as has_listings_with_paid_service_applied,
|
||||
case
|
||||
when total_listings_with_active_product_bundle_with_paid_service > 0
|
||||
then 1
|
||||
else 0
|
||||
end as has_listings_with_active_paid_service_applied,
|
||||
total_bookings_with_product_bundle,
|
||||
total_bookings_with_product_bundle_with_paid_service,
|
||||
case
|
||||
when total_bookings_with_product_bundle > 0 then 1 else 0
|
||||
end as has_bookings_with_product_bundle,
|
||||
case
|
||||
when total_bookings_with_product_bundle_with_paid_service > 0 then 1 else 0
|
||||
end as has_bookings_with_product_bundle_with_paid_service
|
||||
from user_aggregation
|
||||
|
|
@ -2639,4 +2639,131 @@ models:
|
|||
- name: dwh_extracted_at
|
||||
data_type: timestamp with timezone
|
||||
description: |
|
||||
Timestamp of when this row was ingested from the Backend to the DWH.
|
||||
Timestamp of when this row was ingested from the Backend to the DWH.
|
||||
|
||||
|
||||
- name: int_core__new_dash_user_overview
|
||||
description: |
|
||||
This model allows for minimum tracking of how the new dash initative is
|
||||
performing in the different migrations.
|
||||
|
||||
It's a user-centric model in which, for each user, we retrieve some
|
||||
basic performance indicators in the form of listings and bookings.
|
||||
|
||||
columns:
|
||||
- name: id_user_host
|
||||
data_type: string
|
||||
description: |
|
||||
The unique identifier of this table. It corresponds to the host users
|
||||
that have been migrated to the New Dashboard.
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: user_migration_phase
|
||||
data_type: string
|
||||
description: |
|
||||
The migration phase in which this user was migrated, for informative
|
||||
purposes.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: user_estimated_migration_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
The estimated date in which this user was migrated.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: company_name
|
||||
data_type: string
|
||||
description: |
|
||||
Information about the host user.
|
||||
|
||||
- name: first_name
|
||||
data_type: string
|
||||
description: |
|
||||
Information about the host user.
|
||||
|
||||
- name: last_name
|
||||
data_type: string
|
||||
description: |
|
||||
Information about the host user.
|
||||
|
||||
- name: account_currency
|
||||
data_type: string
|
||||
description: |
|
||||
Currency associated to the host user.
|
||||
|
||||
- name: total_user_product_bundles
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of product bundles that this user has or has had.
|
||||
It contains both active and historic cases.
|
||||
|
||||
- name: total_active_user_product_bundles
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of product bundles that this user currently has.
|
||||
It contains only currently active cases.
|
||||
|
||||
- name: total_listings
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of listings that the user owns or has owned.
|
||||
|
||||
- name: total_active_listings
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of listings that the user owns.
|
||||
It contains only those that can accept bookings (hard
|
||||
activation - not to be confused with activity-based
|
||||
segmentation).
|
||||
|
||||
- name: total_listings_with_product_bundle_with_paid_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of listings that have, or have had, a paid service
|
||||
product bundle activated.
|
||||
|
||||
- name: total_listings_with_active_product_bundle_with_paid_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of listings that currently have an active paid service
|
||||
product bundle.
|
||||
|
||||
- name: has_active_listings
|
||||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_active_listings.
|
||||
|
||||
- name: has_listings_with_paid_service_applied
|
||||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_listings_with_product_bundle_with_paid_service.
|
||||
|
||||
- name: has_listings_with_active_paid_service_applied
|
||||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_listings_with_active_product_bundle_with_paid_service.
|
||||
|
||||
- name: total_bookings_with_product_bundle
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of bookings that have a product bundle associated.
|
||||
|
||||
- name: total_bookings_with_product_bundle_with_paid_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Count of bookings that have a product bundle associated that contain
|
||||
a paid service.
|
||||
|
||||
- name: has_bookings_with_product_bundle
|
||||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_bookings_with_product_bundle.
|
||||
|
||||
- name: has_bookings_with_product_bundle_with_paid_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_bookings_with_product_bundle_with_paid_service.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue