diff --git a/apps/workspaces/tasks.py b/apps/workspaces/tasks.py index 2a86b83..1f1bb45 100644 --- a/apps/workspaces/tasks.py +++ b/apps/workspaces/tasks.py @@ -187,7 +187,7 @@ def post_to_integration_settings(workspace_id: int, active: bool): } try: - post_request(url, json.dumps(payload), refresh_token) + post_request(url, payload, refresh_token) org_id = Workspace.objects.get(id=workspace_id).org_id logger.info(f'New integration record: Fyle Quickbooks Desktop (IIF) Integration (ACCOUNTING) | {workspace_id = } | {org_id = }') diff --git a/scripts/python/003_create_integration_records.py b/scripts/python/003_create_integration_records.py new file mode 100644 index 0000000..a2bc503 --- /dev/null +++ b/scripts/python/003_create_integration_records.py @@ -0,0 +1,28 @@ +import logging +from apps.workspaces.models import Workspace +from apps.workspaces.tasks import post_to_integration_settings + +logger = logging.getLogger(__name__) +logger.level = logging.INFO + +processed = failed = 0 + +workspaces = Workspace.objects.filter(onboarding_state='COMPLETE') +for workspace in workspaces: + try: + logger.info(f"Processing workspace: {workspace.id} | {workspace.name}") + post_to_integration_settings(workspace.id, True) + processed += 1 + except Exception as e: + failed += 1 + logger.error( + f"Failed to process workspace {workspace.id}: {str(e)}", + exc_info=True + ) + +logger.info( +f""" +Completed backfill. Total: {workspaces.count()} +Processed: {processed}, Failed: {failed} +""" +) \ No newline at end of file