Merged PR 3914: Include Hubspot deals for KPIs

# Description

Context: I'm intending to work on Account Managers reporting, that mostly will include reporting at Deal level the Resolutions Payouts as well as the new Retained metrics. While checking the great increase on Resolutions Payouts for October 2024:

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

I decided to take a quick look into the main players... and surprise surprise we have Guesty:

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

So Guesty represents 37k over the 73K of October. 50%. Not bad.

The main issue is that we've been aware for months now (since Churn efforts, mostly) that we're not reporting in KPIs those deals that are NOT created in Core. Most notably, API deals which includes... well, Guesty. So creating this kind of in-depth Account Managers improvement without reporting Guesty I think it would be very misleading. Note that the overall figures (Global dimension) are still accurate, though.

What's new:
* A new model named `int_kpis__dimension_deals` that basically retrieves Deals from both Core (as before) and Hubspot. It combines information from both and mostly assumes Hubspot as a better source of information than Core - although we do not have the Main Billing Country there afaik.
* Propagates changes, mostly in the monthly by deal view of Main KPIs. Here I confirm that now Guesty appears, and it only has metrics that come from Xero (APIs Revenue, Total Revenue, Resolutions, etc)

# 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: #25829
This commit is contained in:
Oriol Roqué Paniagua 2024-12-31 15:12:38 +00:00
parent 29a005297a
commit 0d7b5ac88a
6 changed files with 82 additions and 12 deletions

View file

@ -3,7 +3,7 @@ This model aggregates the different metrics by deal for those hosts that have it
*/
with
int_core__deal as (select * from {{ ref("int_core__deal") }}),
int_kpis__dimension_deals as (select * from {{ ref("int_kpis__dimension_deals") }}),
int_kpis__agg_dates_main_kpis as (
select *
from {{ ref("int_kpis__agg_dates_main_kpis") }}
@ -83,9 +83,9 @@ select
d.day,
d.date,
-- DEAL STATIC ATTRIBUTES --
icd.id_deal,
icd.main_deal_name,
icd.main_billing_country_iso_3_per_deal,
ikdd.id_deal,
ikdd.main_deal_name,
ikdd.main_billing_country_iso_3_per_deal,
-- DEAL LIFECYCLE --
daily_deal_lifecycle.deal_lifecycle_state,
@ -208,7 +208,7 @@ select
) as income_retained_post_resolutions_in_gbp
from int_kpis__agg_dates_main_kpis d
left join int_core__deal icd on d.dimension_value = icd.id_deal
left join int_kpis__dimension_deals ikdd on d.dimension_value = ikdd.id_deal
left join
daily_deal_lifecycle
on d.date = daily_deal_lifecycle.date