You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dispatch create-path notifications async to fix slow POST latency (#14731)
* Dispatch create-path notifications async to fix slow POST latency
POST /api/v2/engagements/ takes ~5s on large tenants because
create_notification runs recipient enumeration and per-user Alert
writes on the request thread. Move the outer create_notification to a
Celery worker for the five create-path events (engagement_added,
product_added, product_type_added, finding_added, test_added) by
adding async_create_notification (accepts ids, re-fetches, delegates)
and dispatching via dojo_dispatch_task. This extends the existing
per-user async pattern (Slack/email/MSTeams/webhooks) up one level so
the recipient query and Alert fan-out no longer block the response.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Fix ruff D213 and skip dispatch during fixture loads
- Reformat async_create_notification importer-guard docstring to D213 style
- Skip post_save dispatch when raw=True (loaddata) so the k8s initializer's
fixture install path doesn't require an available Celery broker. Without
this guard the unconditional async dispatch tries to enqueue during
product_type.json load and fails with kombu OperationalError.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* optimize async_create_notification to avoid redundant DB fetches
When test_id + engagement_id + product_id are all passed, the original
implementation fetched each object independently (3 queries). Since
Test.select_related("engagement__product") already loads all three in
one query, derive engagement and product from the test instead.
Same for engagement_id + product_id: one query instead of two.
Also updates the no_async performance test expected counts accordingly.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: valentijnscholten <valentijnscholten@gmail.com>
0 commit comments