Merged PR 2257: Expose guest revenue and guest journey payment metrics

This PR aims to expose the new metrics to the business KPIs report.
The new metrics exposed are, for the global and the by deal view:
- Guest Revenue
- Guest Revenue per Guest Journey Completed
- Guest Revenue per Guest Journey with Payment
- Guest Payments
- Guest Payments per Guest Journey Completed
- Guest Payments per Guest Journey with Payment
- Guest Journey with Payment
- Guest Journey Payment Rate

Changes:
- Silly change on the naming in the by deal view of `payment_rate_guest_journey` to be consistent with the global view.
- Silly change that I miss some GJ payment metric for the view by deal id.
- Added a new number format called `currency_gbp` - only for monetary metrics, available in the schema files
- Usual procedure to publish metrics: for global metrics, add them in the `int_mtd_aggregated_metrics`. I also changed the order of display.
- **Important**: to avoid displaying revenue figures until Xero invoicing is handled, I created a macro called `is_date_before_previous_month` that is called in the reporting equivalent models: `mtd_aggregated_metrics` in the where section and in the `monthly_aggregated_metrics_history_by_deal` as a case-when.

This should allow to expose all new metrics, and enable the publishing of a new update of the business kpis!

Related work items: #18107
This commit is contained in:
Oriol Roqué Paniagua 2024-07-10 14:17:05 +00:00
parent d39bc02ae1
commit 3b75d9eefb
8 changed files with 171 additions and 39 deletions

View file

@ -0,0 +1,18 @@
/*
This macro provides a boolean answer to the question:
- Is this date before the previous month?
The computation is based on the current date by using now()
Inputs:
- date: the date from which you want to check
Output:
- boolean; true for is before the previous month
false for is not before the previous month
*/
{% macro is_date_before_previous_month(date) %}
(
date_trunc('month', ({{ date }})::date)::date
+ interval '1 month'
)::date
< date_trunc('month', now())::date
{% endmacro %}