Skip to content

Commit

Permalink
Merge pull request #397 from Gary-Community-Ventures/feat/hubspot_anu…
Browse files Browse the repository at this point in the history
…al_income

HubSpot Annual Income
  • Loading branch information
CalebPena authored Jun 6, 2024
2 parents 0aee7e3 + 0096293 commit 812d2f3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions integrations/services/hubspot/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def mfb_user_to_hubspot_contact(self, user: User, screen: Screen = None):
contact["ab01___uuid"] = str(screen.uuid)
contact["ab01___county"] = screen.county
contact["ab01___number_of_household_members"] = screen.household_size
contact["ab01___mfb_annual_income"] = int(screen.calc_gross_income("yearly", ["all"]))

members = screen.household_members.all()
if len(members) > self.MAX_HOUSEHOLD_SIZE:
Expand Down
24 changes: 23 additions & 1 deletion screener/one_time_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def update_hubspot_extra_fields():

failed = []

for i in trange(len(screens), desc="Translations"):
for i in trange(len(screens), desc="Contacts"):
screen = screens[i]
user = screen.user
if user.external_id is None or user.external_id == "":
Expand All @@ -317,3 +317,25 @@ def update_hubspot_extra_fields():

print("\n".join(failed))
print("done")


def backfill_hubspot_annual_income_field():
screens = list(Screen.objects.filter(user__isnull=False))
hubspot = Hubspot()

failed = []

for i in trange(len(screens), desc="Contacts"):
screen = screens[i]
user = screen.user
if user.external_id is None or user.external_id == "":
continue

try:
data = {"ab01___mfb_annual_income": int(screen.calc_gross_income("yearly", ["all"]))}
hubspot.update_contact(user.external_id, data)
except Exception:
failed.append(f"failed to update user with id: {user.id} and external id: {user.external_id}")
time.sleep(0.11)

print("\n".join(failed))

0 comments on commit 812d2f3

Please sign in to comment.