From 4cdd47c25fc6d6ae63a81e74090bdebb52bfb357 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 3 Dec 2025 13:02:14 +0000 Subject: [PATCH] fix monthend --- deployment/lambda/lambda_example/docker/app.py | 8 +++++--- etl/hubSpotClient/hubspotClient.py | 16 ++++++++++++++++ etl/month_end_automation_wave_2_no_8.py | 12 +++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/deployment/lambda/lambda_example/docker/app.py b/deployment/lambda/lambda_example/docker/app.py index 48c22cc..3463356 100644 --- a/deployment/lambda/lambda_example/docker/app.py +++ b/deployment/lambda/lambda_example/docker/app.py @@ -1,7 +1,9 @@ from etl.hubSpotClient.hubspotClient import HubSpotClient def handler(event, context): - hubspot = HubSpotClient() + nums = [ + ] - hubspot.add_product_line_item_to_deal("268596250843", "281058046195") - \ No newline at end of file + hubspot = HubSpotClient() + for num in nums: + hubspot.delete_line_item(num) \ No newline at end of file diff --git a/etl/hubSpotClient/hubspotClient.py b/etl/hubSpotClient/hubspotClient.py index bb791e9..2168217 100644 --- a/etl/hubSpotClient/hubspotClient.py +++ b/etl/hubSpotClient/hubspotClient.py @@ -323,3 +323,19 @@ class HubSpotClient(): self.associate_line_item_to_deal(line_item_id, deal_id) return line_item_id + + def delete_line_item(self, line_item_id: str): + """ + Delete (archive) a line item in HubSpot by its ID. + """ + try: + self.logger.info(f"Deleting line item {line_item_id}...") + + self.client.crm.line_items.basic_api.archive(line_item_id) + + self.logger.info(f"Line item {line_item_id} deleted successfully.") + return True + + except ApiException as e: + self.logger.error(f"Failed to delete line item {line_item_id}: {e}") + return False \ No newline at end of file diff --git a/etl/month_end_automation_wave_2_no_8.py b/etl/month_end_automation_wave_2_no_8.py index 1d5784b..3e51c9f 100644 --- a/etl/month_end_automation_wave_2_no_8.py +++ b/etl/month_end_automation_wave_2_no_8.py @@ -149,9 +149,19 @@ design4 = get_df(design4, "design upload to sharepoint", ["done"], "Design Repet if not design4.empty: filtered_dfs.append(design4) -all_filtered = pd.concat([df for df in (design1, design2, design3, design4) if not df.empty]) +dfs_to_concat = [df for df in (design1, design2, design3, design4) if not df.empty] + +# Safe concat +if dfs_to_concat: + all_filtered = pd.concat(dfs_to_concat) +else: + all_filtered = pd.DataFrame() # empty df with no error + +# Rows not matched by any design type design_remaining = design.loc[~design.index.isin(all_filtered.index)] + if not design_remaining.empty: + design_remaining = design_remaining.copy() design_remaining["job_type"] = "design type not specified" filtered_dfs.append(design_remaining)