Commit graph

510 commits

Author SHA1 Message Date
Oriol Roqué Paniagua
409ac47591 Merged PR 2232: KPI refactor - 1st step, bookings
First step on refactor of kpis:
- Remove relative incremental vs. previous year computation from the source model (`mtd_booking_metrics`, in this case)
- Aggregate the source mtd global metrics models into a single model: `int_mtd_vs_previous_year_metrics` (to enable multi-source weighted metric computation) and compute previous year value and relative increment. Now this logic is encapsulated into a macro `calculate_safe_relative_increment`, easing readability and providing a bit more robustness.
- End-to-end continuity to not break the existing dashboard display in `int_core__mtd_aggregated_metrics`

This is a substep of the global change. All info can be found in the documentation [here](https://www.notion.so/knowyourguest-superhog/Refactoring-Business-KPIs-5deb6aadddb34884ae90339402ac16e3)

Related work items: #18202
2024-07-08 15:58:36 +00:00
Pablo Martín
62ad19ea9e Merged PR 2231: Xero Sales Mart
This PR implements a denormalized view of Xero invoice and credit notes data.

This is done because this shaped of data will both enable very simple reporting on some accounting reports, as well as easier modeling in some of the KPIs effort.

I also included a tiny change on dates and times in the invoice models.

Related work items: #17550
2024-07-08 15:52:24 +00:00
Pablo Martin
fad85691f3 typo in docs 2024-07-08 17:52:15 +02:00
Pablo Martin
00b7940c25 more schema, more tests 2024-07-08 17:26:10 +02:00
Pablo Martin
003c7cd185 remove duplicated currency field 2024-07-08 17:26:02 +02:00
Pablo Martin
6fcc9fde16 schema 2024-07-08 17:06:23 +02:00
Pablo Martin
a79288a657 add contact data 2024-07-08 16:55:46 +02:00
Pablo Martin
42811b6c7e propagate field in reporting layer 2024-07-08 16:48:39 +02:00
Pablo Martin
da7b931e8e include header data 2024-07-08 16:47:44 +02:00
Pablo Martin
ff09b2d7a4 propagate field to int 2024-07-08 16:31:53 +02:00
Pablo Martin
43a7ead6d3 missing field in stg 2024-07-08 16:29:35 +02:00
Pablo Martin
7fb5bc90d8 join credit notes 2024-07-08 16:17:20 +02:00
Pablo Martin
0b05f8cb62 join invoices 2024-07-08 16:16:21 +02:00
Pablo Martin
b08695795d line item level 2024-07-08 16:13:37 +02:00
Oriol Roqué Paniagua
d2b0afdca6 Merged PR 2221: Computes (paid) guest revenue metric - fixed
IMPORTANT: this PR was merged and reverted. The division by 0 error has been fixed in the last commit

Adds the following metrics:
- Guest Revenue

by both visions (global and by deal id)
It creates 2 new models:
- int_mtd_guest_revenue_metrics
- int_monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Related work items: #18107
2024-07-08 11:02:02 +00:00
Joaquin Ossa
e214641b9f Merged PR 2218: Fixed join on model taking id_verification instead of id_verification_request
Fixed join on model taking id_verification instead of id_verification_request

Related work items: #16947
2024-07-05 15:41:55 +00:00
Joaquin Ossa
03dbe60b38 Fixed join on model taking id_verification instead of id_verification_request 2024-07-05 17:24:06 +02:00
Oriol Roqué Paniagua
49a3c39b82 Merged PR 2217: Revert 'Computes (paid) guest revenue metric'
Adds the following metrics:

- Guest Revenue
by both visions (global and by deal id)

It creates 2 new models:
- int_core__mtd_guest_revenue_metrics
- int_core__monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Reverts !2199

Related work items: #18107
2024-07-05 15:19:35 +00:00
Joaquin Ossa
34df8a7ef9 Merged PR 2201: Fixing errors raised by texts
Tiny PR to fix errors raised by texts
2024-07-05 15:12:04 +00:00
Oriol Roqué Paniagua
d1362bb1db Merged PR 2199: Computes (paid) guest revenue metric
Adds the following metrics:

- Guest Revenue
by both visions (global and by deal id)

It creates 2 new models:
- int_core__mtd_guest_revenue_metrics
- int_core__monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Related work items: #18107
2024-07-05 15:01:21 +00:00
Joaquin Ossa
2738c8617d Fixing errors raised by texts 2024-07-04 16:41:41 +02:00
Joaquin Ossa
2efc1d8b65 Merged PR 2178: New model for guests satisfaction report
New model for guests satisfaction report, I included columns to check what is the guest paying for that might be helpful for analysis as well

Related work items: #16947
2024-07-04 10:13:11 +00:00
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
5bd6a2c254 Changed case to coalesce 2024-07-03 17:38:00 +02:00
Joaquin Ossa
3b22832d8b Created model in reporting as well with schema 2024-07-03 16:34:33 +02:00
Joaquin Ossa
fb61c69714 Changed names of types of payments for better clarity 2024-07-03 16:23:52 +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
35e4735720 Added date of birth and kept age 2024-07-03 15:18:05 +02:00
Joaquin Ossa
fedf808b6b Added date of adaptation 2024-07-03 15:05:12 +02:00
Joaquin Ossa
5867b53e55 Fixed indentation 2024-07-03 15:01:07 +02:00
Joaquin Ossa
af4ab70b96 Addresed Uri's comments and also included new reports in exposures.ymal 2024-07-03 12:29:01 +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
Joaquin Ossa
0cda63d1a7 New model for guests satisfaction report 2024-07-02 14:22:04 +02: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
28917fcc08 Merged PR 2167: Survey to Staging
Brings the CSAT response table from the backend to staging area.

Related work items: #16947
2024-07-01 15:02:10 +00:00
Pablo Martin
64377da570 PK test 2024-07-01 16:54:58 +02:00
Pablo Martin
83f67a06bf model 2024-07-01 16:53:54 +02:00
Pablo Martin
2f133c1424 add source 2024-07-01 16:50:12 +02: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
883618add1 subquery to CTE 2024-07-01 14:02:13 +02: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
Pablo Martin
0e9c608894 more docs 2024-07-01 11:39:40 +02:00
Pablo Martin
1b942b7506 add col 2024-07-01 11:39:36 +02:00
Pablo Martin
f0f6382bbd update docs 2024-07-01 11:34:26 +02:00