Skip to content

Commit

Permalink
Merge pull request #386 from Gary-Community-Ventures/feat/update_hubs…
Browse files Browse the repository at this point in the history
…pot_users

Add Script to Update User Info in HubSpot
  • Loading branch information
CalebPena authored May 29, 2024
2 parents a1dcc9e + a6e749c commit e626e9b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion programs/programs/urgent_needs/urgent_need_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class EarlyChildhoodMentalHealthSupport(UrgentNeedFunction):
@classmethod
def eligible(cls, screen: Screen):
"""
Return True if the householdh as a child aged 0-5
Return True if the household has a child aged 0-5
"""
return screen.num_children(age_max=cls.max_age) > 0

Expand Down
25 changes: 25 additions & 0 deletions screener/one_time_scripts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from tqdm import trange
from integrations.services.hubspot.integration import Hubspot, upsert_user_hubspot
from .models import (
Screen,
EligibilitySnapshot,
Expand All @@ -8,6 +10,7 @@
)
import json
import uuid
import time


def generate_bwf_snapshots():
Expand Down Expand Up @@ -291,3 +294,25 @@ def fix_insurance():
member.save()

print("done")


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

failed = []

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

try:
hubspot.update_contact(user.external_id, hubspot.mfb_user_to_hubspot_contact(user, screen))
except Exception as e:
failed.append(f"failed to update user with id: {user.id} and external id: {user.external_id}")
time.sleep(0.2)

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

0 comments on commit e626e9b

Please sign in to comment.