From 44b9e97600f8a6d647addfaa66c11282fbd85d63 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 16 Apr 2025 18:02:32 +0000 Subject: [PATCH] added script to for marketing operations --- .github/workflows/hubspot_deal_notes.yml | 29 ++++++++++++++++++++++++ etl/dimitra_hubspot_notes_gather.py | 21 +++++++++++------ 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/hubspot_deal_notes.yml diff --git a/.github/workflows/hubspot_deal_notes.yml b/.github/workflows/hubspot_deal_notes.yml new file mode 100644 index 0000000..ce80afe --- /dev/null +++ b/.github/workflows/hubspot_deal_notes.yml @@ -0,0 +1,29 @@ +name: Deal Notes From HubSpot Scraper +on: + schedule: + - cron: '0 19 * * 0' + workflow_dispatch: + +jobs: + sharepoint-validator: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + pip install poetry + poetry install --no-root + + - name: run script + run: | + pwd + ls -la + poetry run python etl/dimitra_hubspot_notes_gather.py + env: + PYTHONPATH: ${{ github.workspace }} \ No newline at end of file diff --git a/etl/dimitra_hubspot_notes_gather.py b/etl/dimitra_hubspot_notes_gather.py index 923c395..fd3b385 100644 --- a/etl/dimitra_hubspot_notes_gather.py +++ b/etl/dimitra_hubspot_notes_gather.py @@ -1,10 +1,8 @@ import os -os.environ["SHAREPOINT_CLIENT_ID"] = "895e3b77-b1d7-43ec-b18f-dcfe07cdfeaf" -os.environ["SHAREPOINT_CLIENT_SECRET"] = "SOf8Q~-is4wdQiqvEEm9FlJQRAY9ELGaj5Qz-a6E" -os.environ["SHAREPOINT_TENANT_ID"] = "c3f7519c-2719-4547-af04-6da6cbfd8f8f" -os.environ["SOUTH_COAST_INSULATION_SERVICE_SHAREPOINT_ID"] = "b5a51507-9427-4ee0-b03e-90ec7681e2d3" -os.environ["JJC_SERVICE_SHAREPOINT_ID"] = "7fdd0485-bbf3-4b29-b30f-98c81c2a6284" +os.environ["SHAREPOINT_CLIENT_ID"] = "6832a4c5-fb8c-4082-a746-4f51e1020f0d" +os.environ["SHAREPOINT_CLIENT_SECRET"] = "xpC8Q~Frww48SM1V-D8lGy5iOY7P_cJ7FF3jgarQ" +os.environ["SHAREPOINT_TENANT_ID"] = "10d5af8b-2cfd-4882-9ccd-b96e4812dacf" from etl.scraper.scraper import SharePointScraper, SharePointInstaller, previous_monday from etl.hubSpotClient.hubspot import HubSpotClient, DealStage @@ -102,8 +100,17 @@ for pipeline, group_df in df.groupby("pipeline_name"): current_row += 1 # Save to Excel -file_name = "DEAL_NOTES_FROM_HUBSPOT.xlsx" +from datetime import datetime, timedelta +today = datetime.today() +days_ahead = (7 - today.weekday()) % 7 +days_ahead = 7 if days_ahead == 0 else days_ahead # If today is Monday, get *next* Monday +next_monday = today + timedelta(days=days_ahead) + +formatted = next_monday.strftime("Monday %d-%m-%Y") + + +file_name = f"DEAL_NOTES_FROM_HUBSPOT {formatted}.xlsx" wb.save(file_name) output_path = os.path.abspath(file_name) sharepoint_client = SharePointScraper(SharePointInstaller.DOMNA) -sharepoint_client.upload_file(output_path, f"/02. Sales and Marketing/02. DEAL Notes from Hubspot/{previous_monday}",file_name) +sharepoint_client.upload_file(output_path, f"02. Sales and Marketing/02. Deal Notes from Hubspot/{formatted}",file_name)