-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: backfill integration records (#128)
* feat: backfill integration records (cherry picked from commit f84275d) * fix: add error handling and fail count to output * fix: remove `json.dumps` from `post_request` call This behaviour was changed in #125
- Loading branch information
1 parent
a8fbc6d
commit 0393724
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
""" | ||
) |