Merged PR 5246: Ordered services in HS and added new boolean

# Description

Improvements on onboarding data:
* Hubspot services that clients expressed their interest in are now sorted alphabetically. This is needed for:
* A new boolean to compare current active services applied in listings vs. services that captured the interest of the client on onboarding. This can help identify clients that we might need to follow up to ensure all programs are created and applied.

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] 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: #30249
This commit is contained in:
Oriol Roqué Paniagua 2025-05-19 08:40:14 +00:00
parent fea129bcee
commit 8c7c3e84cf
4 changed files with 32 additions and 17 deletions

View file

@ -441,8 +441,9 @@ models:
The services that captured the interest of the potential client
during onboarding calls, for New Dash.
This field has been processed by applying a standardized separation
"|" and an upper case. Be aware that this is not how data is
presented in HubSpot.
"|" and an upper case. Additionally, services are ordered alphabetically
for future comparison with Backend data. Be aware that this is not how
data is presented in HubSpot.
Not to be confused with the actual services that host has applied.
For the later, check backend data.
It can be null.

View file

@ -106,20 +106,16 @@ with
-- a string with multiple values separated by ; and these can contain
-- leading or trailing spaces.
-- In the following field we apply a standardization to the
-- values by replacing the separators with | and converting the values
-- to uppercase. The regex applied is:
-- \s* → Matches any leading or trailing spaces.
-- [;] → Matches ; as separator.
-- \s* → Again, ensures spaces around the separator are also replaced.
-- 'g' → Applies the replacement globally (to all occurrences in the
-- string).
upper(
regexp_replace(
{{ adapter.quote("properties") }} ->> 'services',
'\s*[;]\s*',
'|',
'g'
)
-- values by replacing the separators with |, converting the values
-- to uppercase and ensuring the final order is alphabetically.
(
select string_agg(upper(trim(item)), '|' order by upper(trim(item)))
from
unnest(
string_to_array(
{{ adapter.quote("properties") }} ->> 'services', ';'
)
) as item
) as expressed_service_interest,
{{ adapter.quote("properties") }} as properties,
{{ adapter.quote("createdAt") }} as created_at_utc,