mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
import json
|
|
import os
|
|
import re
|
|
from typing import Any, Dict, List
|
|
|
|
from openpyxl import load_workbook
|
|
|
|
from backend.pashub_fetcher.pashub_to_ara_trigger_request import (
|
|
PashubToAraTriggerRequest,
|
|
)
|
|
from backend.pashub_fetcher.handler.handler import handler
|
|
|
|
if __name__ == "__main__":
|
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
|
filepath: str = os.path.join(
|
|
BASE_DIR,
|
|
"pashub_fetcher",
|
|
"NCHA_SHDF_Wave_3_Main_Operation_Board_PASHUB RAs.xlsx",
|
|
)
|
|
|
|
wb = load_workbook(filepath, data_only=True)
|
|
ws = wb["filtered"]
|
|
|
|
HEADER_ROW = 3
|
|
|
|
headers: Dict[str, int] = {}
|
|
for col in range(1, ws.max_column + 1):
|
|
value = str(ws.cell(row=HEADER_ROW, column=col).value)
|
|
if value:
|
|
headers[value.strip()] = col
|
|
|
|
name_col = headers.get("Name")
|
|
link_col = headers.get("PasHub Link")
|
|
hubspot_deal_id_col = headers.get("HubSpot ID")
|
|
sharepoint_link_col = headers.get("Sharepoint")
|
|
|
|
trigger_requests: List[PashubToAraTriggerRequest] = []
|
|
|
|
for row in range(HEADER_ROW + 1, ws.max_row + 1):
|
|
name = ws.cell(row=row, column=name_col).value if name_col else None
|
|
link = ws.cell(row=row, column=link_col).value if link_col else None
|
|
hubspot_deal_id = (
|
|
ws.cell(row=row, column=hubspot_deal_id_col).value
|
|
if hubspot_deal_id_col
|
|
else None
|
|
)
|
|
sharepoint_link = (
|
|
ws.cell(row=row, column=sharepoint_link_col).value
|
|
if sharepoint_link_col
|
|
else None
|
|
)
|
|
if not name or not link:
|
|
continue
|
|
|
|
match = re.search(r"/jobs/([0-9a-fA-F\-]+)/", str(link))
|
|
if not match:
|
|
continue
|
|
|
|
trigger_requests.append(
|
|
PashubToAraTriggerRequest(
|
|
pashub_link=str(link),
|
|
hubspot_deal_id=str(hubspot_deal_id),
|
|
sharepoint_link=str(sharepoint_link),
|
|
)
|
|
)
|
|
|
|
# ---- Build fake SQS event ----
|
|
event: Dict[str, Any] = {
|
|
"Records": [
|
|
{"body": json.dumps(req.model_dump()), "messageId": str(i)}
|
|
for i, req in enumerate(trigger_requests)
|
|
]
|
|
}
|
|
|
|
context = None
|
|
handler(event, context)
|