Commit graph

135 commits

Author SHA1 Message Date
Joaquin Ossa
2c366414ce Merged PR 2188: Added date of adaptation
Added date of adaptation when hosts first started using check-in cover
2024-07-04 10:08:13 +00:00
Oriol Roqué Paniagua
1781031c9d Merged PR 2195: Computes GJ with Payment and GJ Payment Rate metrics
Adds the following metrics:
- Guest Journey with Payment
- Guest Journey Payment Rate

by both visions (global and by deal id)

**Important**: it does not expose these metrics to the dashboard, this will be done after we have feedback from Ben R. on the paid GJ without GJ completeness. Missing steps to make them appear is to adapt `int_core__mtd_aggregated_metrics` and `int_core__monthly_aggregated_metrics_history_by_deal` and the respective reporting counterparts.

It adapts:
- `int_core__mtd_guest_journey_metrics`
- `int_core__monthly_guest_journey_history_by_deal`

the approaches are similar in the sense that we join with `int_core__verification_payments` and filter by a PAID status, that has been defined in the `dbt_project.yml` in a similar manner as we did with cancelled bookings. It can happen that the same verification request has multiple payments (see screenshot), which in this case we keep the first date in which the paid payment happens. The volume is quite low anyway.

![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2195/attachments/image.png)
code for the screenshot:

```
with pre as (
select
	id_verification_request,
	count(distinct icvp.id_payment) as total_paid_payments
from intermediate.int_core__verification_payments icvp
where icvp.payment_status = 'Paid'
group by 1
)
select
	case when total_paid_payments > 2 then 'more than 2'
	when total_paid_payments = 2 then '2'
	when total_paid_payments = 1 then '1'
	end as payment_volume_category,
	count(1) as vr_volume
from pre
group by 1
order by 2 desc
```

I also added a missing reference in `schema.yaml` int about `int_core__mtd_guest_journey_metrics`

Related work items: #18105
2024-07-04 09:54:41 +00:00
Joaquin Ossa
205bc6534d Modified date name to stick to convention 2024-07-04 08:24:23 +02:00
Joaquin Ossa
6bc26a66ff Changed date name to check_in_cover_added_date and included model in reporting 2024-07-03 17:43:27 +02:00
Joaquin Ossa
3ce81dfdd1 Fixed the filter for check-in cover verification set and changed named to adopted 2024-07-03 16:16:58 +02:00
Joaquin Ossa
fedf808b6b Added date of adaptation 2024-07-03 15:05:12 +02:00
Oriol Roqué Paniagua
ed5d7828a7 Merged PR 2179: Computes aggregated metrics by deal id and exposes it to reporting
This PR creates 2 new models:
- `int_core__monthly_aggregated_metrics_history_by_deal`, which just gathers the information of the previously created models that compute the kpis by deal id.
- `core__monthly_aggregated_metrics_history_by_deal`, effectively a copy from intermediate to reporting

It also includes documentation of these 2 models, differences between these and the `mtd_aggregated_metrics` equivalents and references it to exposures. I took the opportunity to update the documentation of the `core__mtd_aggregated_metrics` now that it's a bit more mature.

This should be the last PR for the first draft of 'by deal' metrics.

Related work items: #17689
2024-07-03 07:06:34 +00:00
Oriol Roqué Paniagua
f9741d6f69 Merged PR 2172: Adding accommodation metrics by deal id
Adding accommodation metrics by deal id with the model `int_core__monthly_accommodation_history_by_deal`.

With this PR, we have the full set of batch 1 metrics by deal id completed, although separated in different tables. Aggregation will come in a separated PR.

Similarly as the previous PR, this one it's a mix between the logic of `int_core__mtd_accommodation_metrics` and the logic existing for the `int_core__monthly_X_history_by_deal` . It also adds the tests in schema.

Related work items: #17689
2024-07-02 09:32:52 +00:00
Oriol Roqué Paniagua
1a4b6b4c14 Merged PR 2171: Adding Guest Journey metrics by deal id
Adding the 6 Guest Journey metrics by deal id by creating the model `int_core__monthly_guest_journey_history_by_deal`

The structure for the deal id detail follows yesterday's approach on bookings, namely `int_core__monthly_booking_history_by_deal`, but considering the metric computation of the guest journey, namely `int_core__mtd_guest_journey_metrics`.

It also adds the dbt tests ensuring that date and id_deal are not null and that the combination of both is unique.

Related work items: #17689
2024-07-02 07:26:20 +00:00
Oriol Roqué Paniagua
010135fb63 Merged PR 2164: Adding booking metrics by deal id for business kpis
This is a first approach to compute some easy metrics for the "deal" based business kpis. At this stage, it contains the information of bookings (created, checkout, cancelled) per deal and month, including both historic months as well as the current one. This do not contain MTD computation because it's overkill to do a MTD at deal level (+ we have 1k deals, so scalability can become a problem in the future)

Models:
- **int_dates_by_deal**: simple model that reads from **int_dates** and just joins it with **unified_users** to retrieve the deals. It will be used as the 'source of truth' for which deals should be considered in a given month, basically, since the first host associated to a deal is created (not necessarily booked)
- **int_core__monthly_booking_history_by_deal**: it contains the history of bookings per deal id in a monthly basis. It should be easy enough to integrate here, in the future and if needed, B2B macro segmentation.

In terms of performance, comparing the model **int_core__monthly_booking_history_by_deal** and **int_core__mtd_booking_metrics** you'll see that I removed the joined with the **int_dates_xxx** in the CTEs. This is because I want to avoid a double join of date & deal that I tried and I stopped after 5 min running. Since this computation is in a monthly basis - no MTD - it's easy enough to just apply the **int_dates_by_deal** on the last part of the query. With this approach, it runs in 7 seconds.

Related work items: #17689
2024-07-01 16:00:14 +00:00
Pablo Martín
915b9d5165 Merged PR 2161: Sign for bank transactions
The bank transactions table coming from Xero has positive amounts for all transactions by default.

Nevertheless, some transactions are receiving and some are sending.

This PR implements sign for transactions amounts throughout the DWH so that aggregations work properly.

I've also left the transaction sign column in some spots since it might be useful for some aggregation wizardry (ie cancel out receiving transactions in resolutions so that counts are more accurate).

Related work items: #17551
2024-07-01 12:02:25 +00:00
Pablo Martin
487f6701e3 apply transaction sign in line items 2024-07-01 11:45:03 +02:00
Pablo Martin
dd5882a564 propagate transaction sign 2024-07-01 11:44:55 +02:00
Joaquin Ossa
256c638b04 Added id_deal to both intermediate and report model 2024-07-01 10:48:00 +02:00
Oriol Roqué Paniagua
a3b1decb08 Merged PR 2158: Allow last day of the month to appear on 1st of month
As today it's 1st of July, the logic of selecting all days of the current month for MTD purposes on the business KPIs is ko, since we select up to yesterday.
This PR allows to consider the last day of the previous month as 'current month' only for the first day of the following month, thus ensuring that the most up-to-date data is always displayed in the MTD tab.

Related work items: #17745
2024-07-01 07:53:38 +00:00
Joaquin Ossa
cab300f7dd Addressed comments 2024-06-27 12:13:27 +02:00
Joaquin Ossa
a4b16e7410 Completed the schema for the model 2024-06-27 10:40:44 +02:00
Joaquin Ossa
9950c4d9ae Fixed merge error 2024-06-27 10:18:29 +02:00
Joaquin Ossa
04de0c8227 Changed name of model 2024-06-27 10:13:18 +02:00
Joaquin Ossa
431182a098 Removed accommodations from the model 2024-06-27 10:11:48 +02:00
Joaquin Ossa
2a897c6ead fixed model name and dump tables 2024-06-27 10:07:47 +02:00
Joaquin Ossa
cbd1b4414f Created int model for host accommodations with check in hero 2024-06-27 10:07:47 +02:00
Oriol Roqué Paniagua
5c12dd3b13 Merged PR 2125: Fixing accommodation host
Fixing accommodation host by using accommodation to user, after discussion with Ben R.
This improves data quality, even though there's some duplicates removal.
I checked and it effectively removes accommodations that mostly were considered as 'Never Booked', thus not a massive impact is expected for the business kpis. But in any case, let's do things properly :)

Related work items: #17538
2024-06-26 14:47:15 +00:00
Pablo Martin
bb17b7a646 put back accidentally removed column that breaks dbt run 2024-06-25 17:20:36 +02:00
Pablo Martin
86ca7411af remove line items: they have their own tables now 2024-06-25 16:41:41 +02:00
Pablo Martin
88e13182a5 convert currency after subtracting in local currency 2024-06-25 16:24:39 +02:00
Pablo Martin
3973f0a4a6 rename field 2024-06-25 15:07:39 +02:00
Pablo Martin
854afffc1c add account code 2024-06-25 15:07:39 +02:00
Pablo Martin
7a9c913b8a line items 2024-06-25 15:07:39 +02:00
Pablo Martin
d86b6b8627 add tests 2024-06-25 15:07:39 +02:00
Pablo Martin
33d072015c remove full jsons with ids 2024-06-25 15:07:39 +02:00
Pablo Martin
25e9d040ff add internal exchange rates 2024-06-25 15:07:39 +02:00
Pablo Martin
bf54548654 table alias 2024-06-25 15:07:39 +02:00
Pablo Martin
200c324b68 add converted fields 2024-06-25 15:07:39 +02:00
Pablo Martin
447cb3926c bring over bank transactions to int 2024-06-25 15:07:39 +02:00
Oriol Roqué Paniagua
6c053a0753 Merged PR 2107: Adds host lifecycle metrics into biz kpis
This PR closes the first draft of the first batch of business kpis. Host logic has changed to be applied at deal id level.
It's mostly an adapted copy-paste from the accommodation counterpart, specifically:
- `int_core__mtd_deal_lifecycle`: computes the historic deal lifecycle. One line for each deal and MTD date. **Important**: _Not all hosts have a deal set. This will need a data quality report for business teams to fix_
- `int_core__mtd_deal_metrics`: computes the aggregation at MTD date level of the metrics per lifecycle state and activity state

Additionally, this PR changes:
- `int_core__mtd_aggregated_metrics`: it includes the new 3 deal metrics and changes the source of the already existing 3 deal metrics from `mtd_booking_metrics` to the new `mtd_deal_metrics`
- `int_core__mtd_booking_metrics`: removes all code needed to compute the remaining deal metrics, speeding it up considerably.

After this PR, the mtd models run (locally) at the following speed:
- `int_core__mtd_accommodation_lifecycle`: 47 sec
- `int_core__mtd_deal_lifecycle`: 3 sec
- `int_core__mtd_accommodation_metrics`: 5 sec
- `int_core__mtd_deal_metrics`: < 1 sec
- `int_core__mtd_booking_metrics`: 8 sec (quite a reduction)
- `int_core__mtd_guest_journey_metrics`: 5 sec
- `int_core__mtd_aggregated_metrics` and `core__mtd_aggregated_metrics`: < 1 sec

Related work items: #17312
2024-06-25 12:20:59 +00:00
Oriol Roqué Paniagua
0655ac8997 Merged PR 2105: Adding listing lifecycle metrics into business KPIs
This PR will compute the listing metrics in an aggregated manner to be displayed in the Main KPIs dashboard, specifically:
- New Listings
- First Time Booked Listings
- Churning Listings
- It also adapts the computation for the already existing metrics of Listings Booked in X months

At code level, it contains the following:
- Adds `int_core__mtd_accommodation_metrics`, which computes the aggregation of the lifecycle of listings at date level (unique), being date the corresponding date from `int_dates_mtd`
- Changes `int_core__mtd_aggregated_metrics` to take the accommodation metrics from the new model. Those 3 already existing (Listings booked in X month) now read from the new model as well.
- Changes `int_core__mtd_booking_metrics` to remove unused computation, making it lighter. Specifically, it removes 1) listing related metrics, since now we have a dedicated model and 2) number of guests booked, since it's not used at all.

The resulting values in local are consistent with what is already reported in the staging report.

Related work items: #17312
2024-06-25 08:14:23 +00:00
Oriol Roqué Paniagua
f23e210129 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
2024-06-21 14:13:42 +00:00
Oriol Roqué Paniagua
ef80637a9b Merged PR 2090: Adding int_core__mtd_accommodation_lifecycle
Adding int_core__mtd_accommodation_lifecycle. Mainly, it recreates the history of the lifecycle of a listing for each date appearing in the MTD dates (so, last day of month + days for current month + days for current month of the previous year).

Implementation of lag function makes it much faster than self-join. Runs in approx 17 seconds (in local)

The logic behind the lifecycle is the same, and the most-up-to-date results in my local show the same values for the new model and the int_core__accommodation model (see screenshots)

previous model:
![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2090/attachments/image.png)

new model:
![image (2).png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2090/attachments/image%20%282%29.png)

Following PRs will focus on readapting logic of int_core__accommodation to avoid the replication of lifecycle computation (just re-use the last available date in int_core__mtd_accommodation_lifecycle) and the creation of the desired metrics for the Biz Overview dashboard, including a refactor of the mtd_bookings to remove the listing logic from there.

Related work items: #17312
2024-06-21 13:59:14 +00:00
Oriol Roqué Paniagua
fe93f594f5 Merged PR 2084: Adding int_core__accommodation
Adding int_core__accommodation

Includes both:
- Main information of the accommodation, mostly coming from stg_core__accommodation and int_core__country.
- Listing lifecycle computation, based on the created bookings from stg_core__bookings. It's just the current state, no history.

Some considerations:
- I opted to use stg_core__bookings and not int_core__bookings. Main reason is in case at some point we want to add listing-based information to the booking table, it would avoid cyclic references.
- I opted to keep all the logic of 1) accommodation info and 2) lifecycle in the same model. This could be easily split into: lifecycle first that reads uniquely from staging and then the int_core__accommodation that could read from the staging version to retrieve accommodation attributes + the lifecycle one. Up to you

I'd suggest to review first the documentation in schema since it explains the logic applied.

Notion page linked to this task: https://www.notion.so/knowyourguest-superhog/Listing-lifecycle-4dc0311b21ca44f8859969e419872ebd

Related work items: #17312
2024-06-20 16:02:16 +00:00
Oriol Roqué Paniagua
839e5fae1b Merged PR 2077: Adding Country to intermediate
Adding Country to intermediate, both model + documentation.

At this stage, the model is set as a view but we can discuss what is the best approach

Related work items: #17312
2024-06-19 15:34:15 +00:00
Oriol Roqué Paniagua
771b226888 Merged PR 2068: Adding cancelled bookings metric
Adding cancelled bookings metric based on the feedback of the tech team. Mainly, the date of a cancelled booking can be considered as the `updated_date_utc` for those bookings with status cancelled, as it's a terminal state and no additional steps should follow.

I also took the opportunity to update:
- The order on the `int_core__mtd_aggregated_metrics`, so it matches the one in the Notion page for the 1st batch, freeing already the space for the order_by numbers for missing metrics
- Make acronyms of alias in the `main_kpi` subquery in `int_core__mtd_booking_metrics` slightly more clear
- Remove empty line at the end of the file in `int_core__mtd_booking_metrics`

Keep in mind that the cancelled bookings metric will be directly available in the dashboard once this PR is approved and DWH re-runs.

Related work items: #17310
2024-06-18 14:58:55 +00:00
Pablo Martin
344419e660 formatting 2024-06-18 13:41:32 +02:00
Pablo Martin
3d3f3fb9ab fix docs 2024-06-18 13:40:36 +02:00
Pablo Martin
27759374b8 add docs and tests 2024-06-18 13:10:47 +02:00
Pablo Martin
662c7b8ba8 remove hardcoded rates and seed, remove docs 2024-06-18 11:35:07 +02:00
Pablo Martin
8b91babad6 remove old table from cte 2024-06-18 11:31:59 +02:00
Pablo Martin
1f9df9ea5c remove old table 2024-06-18 11:24:03 +02:00
Pablo Martin
d96c8b2abb change which field we join on: payment date is not always informed 2024-06-18 11:23:10 +02:00
Pablo Martin
6f625ec7db do both rates to compare and test 2024-06-18 11:13:51 +02:00