Check in Hero users table
This commit is contained in:
parent
7728eb73c1
commit
10f42d1146
4 changed files with 122 additions and 12 deletions
|
|
@ -1,18 +1,17 @@
|
|||
{% set api_name = "CHECKINHEROAPI" %}
|
||||
|
||||
with
|
||||
stg_check_in_hero__checkins as (
|
||||
select * from {{ ref("stg_check_in_hero__checkins") }}
|
||||
),
|
||||
stg_core__apim_user as (select * from {{ ref("stg_core__apim_user") }}),
|
||||
stg_core__apim_user_type as (select * from {{ ref("stg_core__apim_user_type") }}),
|
||||
stg_core__user as (select * from {{ ref("stg_core__user") }})
|
||||
int_core__check_in_hero_users as (
|
||||
select * from {{ ref("int_core__check_in_hero_users") }}
|
||||
)
|
||||
|
||||
select
|
||||
c.id_record,
|
||||
c.id_user_partner,
|
||||
c.id_reservation,
|
||||
c.id_accommodation,
|
||||
chu.id_currency,
|
||||
c.guest_last_name,
|
||||
c.guest_first_name,
|
||||
c.guest_email,
|
||||
|
|
@ -31,7 +30,7 @@ select
|
|||
c.listing_town,
|
||||
c.listing_country,
|
||||
c.listing_postcode,
|
||||
u.company_name,
|
||||
chu.company_name,
|
||||
c.user_email,
|
||||
c.updated_at_utc,
|
||||
c.updated_date_utc,
|
||||
|
|
@ -39,9 +38,4 @@ select
|
|||
c.cosmos_creation_date_utc,
|
||||
c.created_date_utc
|
||||
from stg_check_in_hero__checkins c
|
||||
inner join stg_core__apim_user au on c.id_user_partner = au.id_apim_user
|
||||
inner join
|
||||
stg_core__apim_user_type aut
|
||||
on au.id_apim_user_type = aut.id_apim_user_type
|
||||
and upper(aut.user_type_name) = '{{ api_name }}'
|
||||
left join stg_core__user u on u.id_user = au.id_apim_user
|
||||
inner join int_core__check_in_hero_users chu on c.id_user_partner = chu.id_apim_user
|
||||
|
|
|
|||
|
|
@ -31,6 +31,16 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key to the
|
||||
currency table"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: guest_last_name
|
||||
data_type: text
|
||||
description: Last name of the guest checking in.
|
||||
|
|
|
|||
26
models/intermediate/core/int_core__check_in_hero_users.sql
Normal file
26
models/intermediate/core/int_core__check_in_hero_users.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{% set api_name = "CHECKINHEROAPI" %}
|
||||
|
||||
with
|
||||
stg_core__apim_user as (select * from {{ ref("stg_core__apim_user") }}),
|
||||
stg_core__apim_user_type as (select * from {{ ref("stg_core__apim_user_type") }}),
|
||||
stg_core__user as (select * from {{ ref("stg_core__user") }})
|
||||
select
|
||||
au.id_apim_user,
|
||||
au.id_apim_user_type,
|
||||
u.id_account_currency as id_currency,
|
||||
au.json_document_user_data ->> 'DealId' as id_deal,
|
||||
au.json_document_user_data ->> 'AccountType' as account_type,
|
||||
au.json_document_user_data ->> 'ClientMarkup' as client_markup,
|
||||
(au.json_document_user_data ->> 'BookingFee')::decimal
|
||||
as booking_fee_in_local_currency,
|
||||
u.company_name,
|
||||
au.created_at_utc,
|
||||
au.created_date_utc,
|
||||
au.updated_at_utc,
|
||||
au.updated_date_utc
|
||||
from stg_core__apim_user au
|
||||
inner join
|
||||
stg_core__apim_user_type aut
|
||||
on au.id_apim_user_type = aut.id_apim_user_type
|
||||
and upper(aut.user_type_name) = '{{ api_name }}'
|
||||
inner join stg_core__user u on au.id_apim_user = u.id_user
|
||||
|
|
@ -4719,3 +4719,83 @@ models:
|
|||
Date of when this user was last updated.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: int_core__check_in_hero_users
|
||||
description: |
|
||||
"Contains information about CheckIn Hero API users.
|
||||
It includes all user details related with the service."
|
||||
columns:
|
||||
- name: id_apim_user
|
||||
data_type: character varying
|
||||
description: "Identifier of the User. Acts as primary
|
||||
key for this table."
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: id_apim_user_type
|
||||
data_type: bigint
|
||||
description: "Identifier of the type of user."
|
||||
|
||||
- name: id_currency
|
||||
data_type: bigint
|
||||
description: "Id of the currency, works as a foreign key to the
|
||||
currency table"
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: id_deal
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: account_type
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: client_markup
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: booking_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Fee charged to the user for each booking in the local currency."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1000
|
||||
strictly: true
|
||||
|
||||
- name: company_name
|
||||
data_type: text
|
||||
description: Company name of partner user.
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this user was created.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this user was created.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this user was last updated.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this user was last updated.
|
||||
tests:
|
||||
- not_null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue