From 2332ab5c0d27fb6fb707bcbeab919a59b1779f00 Mon Sep 17 00:00:00 2001 From: Owen Yamauchi Date: Wed, 15 May 2024 10:45:16 -0400 Subject: [PATCH] A few more item groups (#160) ## Description After going through all the existing incentives and giving them more granular items, I found some common combinations that are worth handling: door/window replacement, and audits plus weatherization. There was one combined incentive (CO's state tax credit for air source heat pumps and HPWHs) which I elected to split into two incentives; it felt too awkward to create a group for those technologies. ## Test Plan Unit test. I found all the multi-item combos in the incentives data by running this in the incentives repo: `echo data/**/incentives.json | xargs jq '.[] | select((.items | length) > 1) | .items | sort | join(",")' | sort | uniq` There are no combos in there that will result in null here. --- src/i18n/strings/es.ts | 2 ++ src/item-name.ts | 65 ++++++++++++++++++++++++++--------------- test/item-names.test.ts | 4 ++- translations/es.xlf | 10 +++++++ 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/i18n/strings/es.ts b/src/i18n/strings/es.ts index dbe06ab..3c1d9c8 100644 --- a/src/i18n/strings/es.ts +++ b/src/i18n/strings/es.ts @@ -11,6 +11,7 @@ export const templates = { s025c15001425a689: `reemplazo de ventanas`, s04009ba1826b5fca: `Idaho`, s04c4b18eb3941d37: `California`, + s07607bad0f288304: `reemplazo de puertas y ventanas`, s07ecbff17886eb50: `un vehículo eléctrico usado`, s08fb6007b5965c82: `Vehículo eléctrico`, s0ec469a91a15f4a5: `kilovatio hora`, @@ -95,6 +96,7 @@ export const templates = { s6ef16f759a2cea7e: `Nevada`, s70fd14cbb0ad4160: `Continúe para ver otros incentivos.`, s751ba5ac47cbfabb: `Washington`, + s7709947cefee8560: `una auditoría energética y impermeabilización`, s777612e8117ff021: `Tennessee`, s79fd9ba9e498d3da: str`${0} del costo de ${1}, hasta \$${2}`, s7a73c90a7c3b43b4: `un calentador de agua con bomba de calor`, diff --git a/src/item-name.ts b/src/item-name.ts index 64a93a2..d8b004d 100644 --- a/src/item-name.ts +++ b/src/item-name.ts @@ -9,10 +9,33 @@ type ItemGroup = | 'plugin_hybrid' | 'new_vehicle' | 'used_vehicle' + | 'door_and_window' | 'insulation' | 'weatherization' + | 'audit_and_weatherization' | 'water_heater'; +const ALL_INSULATION: ItemType[] = [ + 'attic_or_roof_insulation', + 'basement_insulation', + 'crawlspace_insulation', + 'floor_insulation', + 'other_insulation', + 'wall_insulation', +]; + +const ALL_WEATHERIZATION: ItemType[] = [ + ...ALL_INSULATION, + 'air_sealing', + 'door_replacement', + 'duct_replacement', + 'duct_sealing', + 'weatherization', + 'window_replacement', + 'efficiency_rebates', + 'other_weatherization', +]; + /** * Some incentives are for multiple items. These groups define headlines for * such incentives: if the incentive's items are a subset of one of these @@ -67,35 +90,21 @@ const ITEM_GROUPS: { group: ItemGroup; members: Set }[] = [ group: 'used_vehicle', members: new Set(['used_electric_vehicle', 'used_plugin_hybrid_vehicle']), }, + { + group: 'door_and_window', + members: new Set(['door_replacement', 'window_replacement']), + }, { group: 'insulation', - members: new Set([ - 'attic_or_roof_insulation', - 'basement_insulation', - 'crawlspace_insulation', - 'floor_insulation', - 'other_insulation', - 'wall_insulation', - ]), + members: new Set(ALL_INSULATION), }, { group: 'weatherization', - members: new Set([ - 'air_sealing', - 'attic_or_roof_insulation', - 'basement_insulation', - 'crawlspace_insulation', - 'door_replacement', - 'duct_replacement', - 'duct_sealing', - 'floor_insulation', - 'wall_insulation', - 'weatherization', - 'window_replacement', - 'efficiency_rebates', - 'other_insulation', - 'other_weatherization', - ]), + members: new Set(ALL_WEATHERIZATION), + }, + { + group: 'audit_and_weatherization', + members: new Set([...ALL_WEATHERIZATION, 'energy_audit']), }, { group: 'water_heater', @@ -139,12 +148,20 @@ const multipleItemsName = (items: ItemType[], msg: MsgFn) => { }); case 'generic_heat_pump': return msg('a heat pump', { desc: 'e.g. "$100 off [this string]"' }); + case 'door_and_window': + return msg('door and window replacement', { + desc: 'e.g. "$100 off [this string]"', + }); case 'insulation': return msg('insulation', { desc: 'e.g. "$100 off [this string]"' }); case 'weatherization': return msg('weatherization', { desc: 'e.g. "$100 off [this string]"', }); + case 'audit_and_weatherization': + return msg('an energy audit and weatherization', { + desc: 'e.g. "$100 off [this string]"', + }); case 'water_heater': return msg('a water heater', { desc: 'e.g. "$100 off [this string]"', diff --git a/test/item-names.test.ts b/test/item-names.test.ts index 80e7377..81d9d3c 100644 --- a/test/item-names.test.ts +++ b/test/item-names.test.ts @@ -25,7 +25,9 @@ describe('group names', () => { expect(itemName(['wall_insulation', 'other_weatherization'], msg)).toBe( 'weatherization', ); - expect(itemName(['other_weatherization', 'energy_audit'], msg)).toBeNull(); + expect(itemName(['other_weatherization', 'energy_audit'], msg)).toBe( + 'an energy audit and weatherization', + ); }); test('vehicles', () => { diff --git a/translations/es.xlf b/translations/es.xlf index 0d9b0e6..87cb924 100644 --- a/translations/es.xlf +++ b/translations/es.xlf @@ -795,6 +795,16 @@ un vehículo usado e.g. "$100 off [this string]" + + door and window replacement + reemplazo de puertas y ventanas + e.g. "$100 off [this string]" + + + an energy audit and weatherization + una auditoría energética y impermeabilización + e.g. "$100 off [this string]" +