mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
new files
This commit is contained in:
parent
db61f59168
commit
a4f6bc1f62
6 changed files with 41 additions and 29 deletions
|
|
@ -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
|
||||
poetry run python etl/hubSpotClient/scripts/hubspot_update_script.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):
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.")
|
||||
31
etl/hubSpotClient/scripts/hubspot_update_script.py
Normal file
31
etl/hubSpotClient/scripts/hubspot_update_script.py
Normal file
|
|
@ -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.")
|
||||
Loading…
Add table
Reference in a new issue