Implement GraphQL queries for Pulse activity events - #5381
Conversation
…t into pulse-activityevent-model
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
Summary by CodeRabbit
WalkthroughThe pull request adds an ChangesActivity event lifecycle
Local development volume configuration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/apps/github/common.py`:
- Line 142: Wrap each inline ActivityEvent.update_data call in sync_repository,
including the issue, pull request, and release/contributor paths, with exception
handling that logs the failure and allows synchronization to continue. Keep the
primary repository sync flow unchanged apart from isolating these derived-data
errors.
- Around line 223-224: Verify whether Release.bulk_save, via
BulkSaveModel.bulk_save, populates primary keys when persisting releases with
conflict handling. If it does not, refetch the saved releases by node_id after
Release.bulk_save and before the ActivityEvent.update_data loop, then pass those
instances so each event receives a non-null pk; preserve the existing behavior
when primary keys are already populated.
In `@backend/src/apps/owasp/api/internal/queries/activity_event.py`:
- Around line 43-48: Update the ordering in activity_event.py at lines 43-48 to
sort by occurred_at and then pk in the same ascending direction; also update
lines 93-96 to sort by -occurred_at and then -pk. Apply these changes in the
query methods constructing the ActivityEvent querysets.
In `@backend/src/apps/owasp/models/activity_event.py`:
- Around line 175-204: Replace per-object writes in ActivityEvent.update_data
with a bulk entry point, reusing the existing ActivityEvent.bulk_save symbol.
Have it accept many model objects, resolve ContentType once per model class,
collect valid event rows, and persist them with
bulk_create(ignore_conflicts=True) using the unique constraint. Update
sync_repository to call this bulk entry point after each issue, pull request,
and release sync loop rather than calling update_data inside the loops.
- Around line 30-40: Update the activity event uniqueness constraint in the
model to use only activity_type, content_type, and object_id, and adjust
update_data so occurred_at is passed through defaults rather than the lookup
fields. Add a migration that removes the existing constraint, de-duplicates
conflicting rows before creating the new constraint, and preserves the
appropriate row data while consolidating duplicates.
In `@backend/tests/unit/apps/github/common_test.py`:
- Line 24: Add assertions for ActivityEvent.update_data in the three named
tests: verify it receives the synced issue in
test_skips_issues_that_are_pull_requests, the synced pull request in
test_syncs_assignees_on_pull_request, and is called once for each saved release
in test_release_bulk_save_with_new_release, preserving the expected ordering
relative to Release.bulk_save.
In `@docker-compose/local/compose.override.yaml`:
- Around line 2-13: Remove the explicit name properties from the development
volume definitions backend-venv, cache-data, db-data, docs-venv, frontend-next,
and frontend-node-modules so Docker Compose applies project-scoped names. Check
related Compose files and local workflows for references to the fixed volume
names, updating only references that depend on those names while preserving
intentional sharing behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 38ec6562-7cfd-44b8-a9e2-bb3c6178918d
📒 Files selected for processing (11)
backend/src/apps/github/common.pybackend/src/apps/owasp/admin/__init__.pybackend/src/apps/owasp/admin/activity_event.pybackend/src/apps/owasp/api/internal/nodes/activity_event.pybackend/src/apps/owasp/api/internal/queries/__init__.pybackend/src/apps/owasp/api/internal/queries/activity_event.pybackend/src/apps/owasp/migrations/0073_activityevent.pybackend/src/apps/owasp/models/__init__.pybackend/src/apps/owasp/models/activity_event.pybackend/tests/unit/apps/github/common_test.pydocker-compose/local/compose.override.yaml
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/apps/owasp/api/internal/queries/activity_event.py`:
- Around line 46-49: Update both ActivityEvent querysets in activity_event.py—at
the paginated queryset around lines 46-49 and the recent-events queryset around
lines 98-101—to prefetch ActivityEvent.source_object alongside the existing
related objects before slicing or returning results, so ActivityEventNode’s
source_number, source_title, and source_url access does not trigger per-event
lookups.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7274b9db-347e-40c4-8473-f7f80e8bde25
📒 Files selected for processing (2)
backend/src/apps/owasp/api/internal/queries/activity_event.pybackend/src/apps/owasp/models/activity_event.py
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/owasp-pulse #5381 +/- ##
=======================================================
- Coverage 98.83% 98.42% -0.42%
=======================================================
Files 538 542 +4
Lines 17123 17299 +176
Branches 2460 2480 +20
=======================================================
+ Hits 16924 17027 +103
- Misses 99 172 +73
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
Re-trigger cubic
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
|



Proposed change
This PR adds Graphql queries for OWASP Pulse
Resolves #4672
Checklist