diff --git a/.github/workflows/hubspot_abri_sync.yml b/.github/workflows/hubspot_sync.yml similarity index 91% rename from .github/workflows/hubspot_abri_sync.yml rename to .github/workflows/hubspot_sync.yml index d2e89f9..9c4fd63 100644 --- a/.github/workflows/hubspot_abri_sync.yml +++ b/.github/workflows/hubspot_sync.yml @@ -1,4 +1,4 @@ -name: Hubspot Sync Abri +name: Hubspot Sync on: schedule: @@ -6,7 +6,7 @@ on: workflow_dispatch: jobs: - hubspot-sync-abri: + hubspot-sync: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -28,4 +28,4 @@ jobs: run: | pwd ls -la - poetry run python etl/hubSpotClient/scripts/hubspot_update_abri_script.py \ No newline at end of file + poetry run python etl/hubSpotClient/scripts/hubspot_update_script.py \ No newline at end of file diff --git a/etl/db/hubSpotLoad.py b/etl/db/hubSpotLoad.py index 4226446..b09e0eb 100644 --- a/etl/db/hubSpotLoad.py +++ b/etl/db/hubSpotLoad.py @@ -8,7 +8,7 @@ class HubspotTodb(): def new_record_to_hubspot_data(self, deal_data, company, listing): print("This has been depreciated using new interface") - self.upsert_hubspot_deal(self, deal_data, company, listing) + self.upsert_hubspot_deal(deal_data, company, listing) def new_record_company(self, company_data): diff --git a/etl/hubSpotClient/hubspotClient.py b/etl/hubSpotClient/hubspotClient.py index 0dc047e..29a40fa 100644 --- a/etl/hubSpotClient/hubspotClient.py +++ b/etl/hubSpotClient/hubspotClient.py @@ -6,6 +6,8 @@ from hubspot.crm.associations import ApiException class Companies(Enum): ABRI = "237615001799" + SOUTHERN_HOUSING_GROUP = "109343619305" + LIVEWEST = "86205872354" class DealStage(Enum): SURVEYED_COMPLETE_NEEDS_SIGN_OFF = "1617223914" diff --git a/etl/hubSpotClient/scripts/hubspot_abri_etl_first_time.py b/etl/hubSpotClient/scripts/hubspot_abri_etl_first_time.py index 9dc4e4c..6f35fb5 100644 --- a/etl/hubSpotClient/scripts/hubspot_abri_etl_first_time.py +++ b/etl/hubSpotClient/scripts/hubspot_abri_etl_first_time.py @@ -20,8 +20,11 @@ deals = hubspot.get_deal_ids_by_pipeline( # deals from companies we care about valueable_deals = [ - Companies.ABRI.value + Companies.ABRI.value, + Companies.LIVEWEST.value, + Companies.SOUTHERN_HOUSING_GROUP.value, ] + deals_to_add = [] diff --git a/etl/hubSpotClient/scripts/hubspot_update_abri_script.py b/etl/hubSpotClient/scripts/hubspot_update_abri_script.py deleted file mode 100644 index 3c82de9..0000000 --- a/etl/hubSpotClient/scripts/hubspot_update_abri_script.py +++ /dev/null @@ -1,24 +0,0 @@ -from etl.hubSpotClient.hubspotClient import HubSpotClient, Companies, Pipeline -from tqdm import tqdm -from etl.db.hubSpotLoad import HubspotTodb - -hubspot = HubSpotClient() -hubspot.get_deal_stages() -db = HubspotTodb() - -records = db.find_all_deals_with_company_id(Companies.ABRI.value) - -updated_count = 0 # Counter for deals that needed updating -checked_count = 0 # Optional: total processed counter - -for deal in tqdm(records, desc="Checking HubSpot deals"): - checked_count += 1 - was_up_to_date = db.update_deal(deal, hubspot) - - # update_deal() returns False when discrepancies are found - if not was_up_to_date: - updated_count += 1 - -print(f"\nāœ… Finished checking {checked_count} deals.") -print(f"🧩 {updated_count} deal(s) were updated.") -print(f"šŸ“ˆ {checked_count - updated_count} deal(s) were already up to date.") \ No newline at end of file diff --git a/etl/hubSpotClient/scripts/hubspot_update_script.py b/etl/hubSpotClient/scripts/hubspot_update_script.py new file mode 100644 index 0000000..9c52d89 --- /dev/null +++ b/etl/hubSpotClient/scripts/hubspot_update_script.py @@ -0,0 +1,31 @@ +from etl.hubSpotClient.hubspotClient import HubSpotClient, Companies, Pipeline +from tqdm import tqdm +from etl.db.hubSpotLoad import HubspotTodb + +hubspot = HubSpotClient() +hubspot.get_deal_stages() +db = HubspotTodb() + +companies = [ + Companies.ABRI, + Companies.LIVEWEST, + Companies.SOUTHERN_HOUSING_GROUP, +] + +for company in companies: + records = db.find_all_deals_with_company_id(company.value) + + updated_count = 0 # Counter for deals that needed updating + checked_count = 0 # Optional: total processed counter + + for deal in tqdm(records, desc="Checking HubSpot deals"): + checked_count += 1 + was_up_to_date = db.update_deal(deal, hubspot) + + # update_deal() returns False when discrepancies are found + if not was_up_to_date: + updated_count += 1 + + print(f"\nāœ… Finished checking {checked_count} deals for company {company.name}.") + print(f"🧩 {updated_count} deal(s) were updated.") + print(f"šŸ“ˆ {checked_count - updated_count} deal(s) were already up to date.") \ No newline at end of file