Skip to content

Commit

Permalink
update sql and language for DDO (#2305)
Browse files Browse the repository at this point in the history
"Your landlord owns XXX buildings" was still referencing the old WOW portfolio method. This PR updates this count to use the new method by removing all references to the get_assoc_addrs_from_bbl sql function inside data-driven-onboarding.sql and instead adds an extra CTE within that query to get all the wow_bldgs records associated with a bbl in the wow_portfolios table.

We also change the language to say "your landlord is associated with XXX buildings" to keep wording consistent with WOW.
  • Loading branch information
austensen authored May 26, 2022
1 parent 30691a0 commit 607e3a0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
35 changes: 24 additions & 11 deletions data_driven_onboarding/data-driven-onboarding.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ with Total_Res_Units as(
bbl -- is this necessary?
from pluto_19v2
where bbl= %(bbl)s
),
),

-- table of information about all properties associated with a a BBL, using
-- the new WOWZA portfolio mapping algorithm. This replaces the previous
-- get_assoc_addrs_from_bbl() function
Assoc_Bldgs as (
select bldgs.*
from wow.wow_bldgs as bldgs
where bldgs.bbl in (
select unnest(bbls)
from wow.wow_portfolios
where %(bbl)s = any(bbls)
)
),

-- sum of res units in associated portfolio (get_assoc_addrs_from_bbl)
-- count of buildings in associated portfolio (get_assoc_addrs_from_bbl)
-- sum of res units in associated portfolio (Assoc_Bldgs)
-- count of buildings in associated portfolio (Assoc_Bldgs)
Count_Of_Assoc_Bldgs as (
select
case
Expand All @@ -23,7 +36,7 @@ Count_Of_Assoc_Bldgs as (
count (distinct zip) filter (where bbl is not null) as NumberOfAssociatedZips,
sum(unitsres) as NumberOfResUnitsinPortfolio,
sum(evictions) as NumberOfEvictionsinPortfolio
from get_assoc_addrs_from_bbl(%(bbl)s)
from Assoc_Bldgs
group by (Enteredbbl)
),

Expand All @@ -35,7 +48,7 @@ Major_Boro_Of_Assoc_Bldgs as (
end as Enteredbbl,
boro,
count(*) filter (where bbl is not null) NumberOfAssocBldgs
from get_assoc_addrs_from_bbl(%(bbl)s)
from Assoc_Bldgs
group by (Enteredbbl, boro)
order by NumberOfAssocBldgs desc
limit 1
Expand Down Expand Up @@ -98,7 +111,7 @@ violation_lengths_for_portfolio as(
select
bbl
from
get_assoc_addrs_from_bbl(%(bbl)s)
Assoc_Bldgs
)
),

Expand Down Expand Up @@ -177,29 +190,29 @@ select
HPDV.ClassCTotal as hpd_open_class_c_violation_count,

-- number of associated buildings from portfolio
-- drawn from function get_assoc_addrs_from_bbl
-- drawn from Assoc_Bldgs
-- will return null if value is unknown or if there are no associated buildings
A.NumberOfAssociatedBuildings as associated_building_count,

-- number of distinct zip codes of associated buildings from portfolio
-- drawn from function get_assoc_addrs_from_bbl
-- drawn from Assoc_Bldgs
-- will return null if value is unknown or if there are no associated buildings
A.NumberOfAssociatedZips as associated_zip_count,

-- number of residential units in portfolio
-- drawn from function get_assoc_addrs_from_bbl
-- drawn from Assoc_Bldgs
-- will return null if value is unknown or if there are no associated buildings
A.NumberOfResUnitsinPortfolio as portfolio_unit_count,

--number of evictions from associated buildings in portfolio
A.NumberOfEvictionsinPortfolio as number_of_evictions_from_portfolio,
-- the most common borough for buildings in the portfolio
-- drawn from function get_assoc_addrs_from_bbl
-- drawn from Assoc_Bldgs
-- will return null if value is unknown or if there are no associated buildings
MB.boro as portfolio_top_borough,

-- the number of buildings in the portfolio's most common borough
-- drawn from function get_assoc_addrs_from_bbl
-- drawn from Assoc_Bldgs
-- will return null if value is unknown or if there are no associated buildings
MB.NumberOfAssocBldgs as number_of_bldgs_in_portfolio_top_borough,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const useBuildingIntroCard: ActionCardPropsCreator = (
? [
data.associatedBuildingCount && data.portfolioUnitCount && (
<Trans>
Your landlord owns{" "}
Your landlord is associated with{" "}
<Plural
value={data.associatedBuildingCount}
one="one building"
Expand Down
8 changes: 4 additions & 4 deletions locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -3166,6 +3166,10 @@ msgstr "Your landlord"
msgid "Your landlord can't enter your unit whenever they want. Create a formal request which asks your landlord to follow proper protocol and respect your right to privacy."
msgstr "Your landlord can't enter your unit whenever they want. Create a formal request which asks your landlord to follow proper protocol and respect your right to privacy."

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:149
msgid "Your landlord is associated with {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"
msgstr "Your landlord is associated with {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:208
msgid "Your landlord is associated with {buildings, plural, one {one building} other {# buildings}}."
msgstr "Your landlord is associated with {buildings, plural, one {one building} other {# buildings}}."
Expand All @@ -3191,10 +3195,6 @@ msgstr "Your landlord or management company's email"
msgid "Your landlord or management company's information"
msgstr "Your landlord or management company's information"

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:149
msgid "Your landlord owns {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"
msgstr "Your landlord owns {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"

#: frontend/lib/laletterbuilder/letter-builder/choose-letter.tsx:52
#: frontend/lib/laletterbuilder/letter-builder/choose-letter.tsx:58
msgid "Your landlord's contact details"
Expand Down
8 changes: 4 additions & 4 deletions locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -3171,6 +3171,10 @@ msgstr "el dueño de tu edificio"
msgid "Your landlord can't enter your unit whenever they want. Create a formal request which asks your landlord to follow proper protocol and respect your right to privacy."
msgstr ""

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:149
msgid "Your landlord is associated with {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"
msgstr ""

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:208
msgid "Your landlord is associated with {buildings, plural, one {one building} other {# buildings}}."
msgstr "El proprietario de tu edificio está asociado con {buildings, plural, one {un edificio} other {# edificios}}."
Expand All @@ -3196,10 +3200,6 @@ msgstr "La dirección de correo electrónico del dueño o manager de tu edificio
msgid "Your landlord or management company's information"
msgstr "Los datos del dueño o manager de tu edificio"

#: frontend/lib/data-driven-onboarding/data-driven-onboarding.tsx:149
msgid "Your landlord owns {0, plural, one {one building} other {# buildings}} and {1, plural, one {one unit.} other {# units.}}"
msgstr "El dueño de tu edificio posee {0, plural, one {un edificio} other {# edificios}} y {1, plural, one {una unidad.} other {# unidades.}}"

#: frontend/lib/laletterbuilder/letter-builder/choose-letter.tsx:52
#: frontend/lib/laletterbuilder/letter-builder/choose-letter.tsx:58
msgid "Your landlord's contact details"
Expand Down

0 comments on commit 607e3a0

Please sign in to comment.