From 8ab00146aaa7748a4891e1453412a19c21784684 Mon Sep 17 00:00:00 2001 From: n0str Date: Tue, 2 Jul 2024 23:34:17 +0300 Subject: [PATCH] remove history report --- main.py | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/main.py b/main.py index fa963d3..2460948 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ changes_limit = 10 figma_api = FigmaAPI.load_from_env() -def generate_report(event, created, modified, history_diff): +def generate_report(event, created, modified): def insert_link_to_path(path): nodes = re.findall(r'(\d+[-:]\d+)', path) for node in nodes: @@ -51,29 +51,6 @@ def insert_link_to_path(path): if len(modified) > limit: lines.append(f"and {len(modified)-limit} more") - lines.append(f"\nChanges\n") - - changes = [] - for component in history_diff['dict:add']: - component["path"] = insert_link_to_path(component["path"]) - changes.append(f"- Add {component['value'][1]} on path {component['path']}") - - for component in history_diff['list:add']: - component["path"] = insert_link_to_path(component["path"]) - if isinstance(component['value'], str): - changes.append(f"- Set {component['value']} on path {component['path']}") - else: - changes.append(f"- Set {component['value'][1]} on path {component['path']}") - for component in history_diff['value_changes']: - component["path"] = insert_link_to_path(component["path"]) - if component['path'] in ['thumbnailUrl', 'lastModified', 'version']: - continue - changes.append(f"- Change {component['path']} from {component['old']} to {component['new']}") - - lines.extend(changes[:changes_limit]) - if len(changes) > changes_limit: - lines.append(f"and {len(changes)-changes_limit} more") - return "\n".join(lines) @@ -99,25 +76,8 @@ def store_json(): created = event_parser.created_components() modified = event_parser.modified_components() - component_ids = created['component_ids'] | modified['component_ids'] - if 'file_key' in event: - versions = figma_api.get_versions(event['file_key']) - history_new = figma_api.get_history(event['file_key'], list(component_ids), versions[0]) - history_old = figma_api.get_history(event['file_key'], list(component_ids), versions[1]) - - with open(f"{prefix}-new.json", "w") as w: - w.write(json.dumps(history_new)) - - with open(f"{prefix}-old.json", "w") as w: - w.write(json.dumps(history_old)) - - diff_report = event_parser.generate_history_diff(history_old, history_new) - - with open("{prefix}-diff.json", "w") as w: - w.write(json.dumps(diff_report)) - - message = generate_report(event, created['components'], modified['components'], diff_report) + message = generate_report(event, created['components'], modified['components']) with open("{prefix}-message.txt", "w") as w: w.write(message)