Skip to content

Implement GraphQL queries for Pulse activity events - #5381

Open
anurag2787 wants to merge 11 commits into
OWASP:feature/owasp-pulsefrom
anurag2787:pulse-graphql
Open

Implement GraphQL queries for Pulse activity events#5381
anurag2787 wants to merge 11 commits into
OWASP:feature/owasp-pulsefrom
anurag2787:pulse-graphql

Conversation

@anurag2787

@anurag2787 anurag2787 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Proposed change

This PR adds Graphql queries for OWASP Pulse

Resolves #4672

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran all required checks and tests locally; all warnings addressed and failures resolved
  • I used AI for code, documentation, tests, or communication related to this PR

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Contribution validation failed:

@anurag2787
anurag2787 changed the base branch from main to feature/owasp-pulse August 7, 2026 16:24
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Contribution validation failed:

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added activity tracking for GitHub issues, pull requests, and releases.
    • Added OWASP API access to activity events with pagination, sorting, and filters for users, projects, chapters, time ranges, and bots.
    • Added event details including activity type, timestamp, source title, URL, and repository information.
    • Added administrative tools for reviewing, filtering, and searching recorded activity.
  • Bug Fixes
    • Prevented duplicate activity records and excluded events without valid timestamps.

Walkthrough

The pull request adds an ActivityEvent model for GitHub issues, pull requests, and releases. GitHub synchronization records events. GraphQL queries and Django admin expose them. Local Compose volumes receive persistent names.

Changes

Activity event lifecycle

Layer / File(s) Summary
Activity event model and persistence
backend/src/apps/owasp/models/activity_event.py, backend/src/apps/owasp/models/__init__.py, backend/src/apps/owasp/migrations/0073_activityevent.py
Adds the ActivityEvent model, migration, event builders, source metadata, filtering helpers, bot exclusion, and persistence orchestration.
GitHub synchronization event creation
backend/src/apps/github/common.py, backend/tests/unit/apps/github/common_test.py
Records activity events after issue, pull request, and release synchronization. Updates the shared dependency fixture.
Activity event GraphQL API
backend/src/apps/owasp/api/internal/nodes/activity_event.py, backend/src/apps/owasp/api/internal/queries/activity_event.py, backend/src/apps/owasp/api/internal/queries/__init__.py
Adds activity event nodes, paginated and recent-event queries, filtering, ordering, pagination validation, and query registration.
Activity event administration
backend/src/apps/owasp/admin/activity_event.py, backend/src/apps/owasp/admin/__init__.py
Registers ActivityEvent in Django admin with autocomplete, display, filtering, and search configuration.

Local development volume configuration

Layer / File(s) Summary
Persistent local development volumes
docker-compose/local/compose.override.yaml
Adds named persistent volumes for local backend, frontend, database, cache, and documentation data.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • OWASP/Nest#5233: Implements the same ActivityEvent model, GitHub synchronization, admin/API exposure, migration, and supporting changes.
  • OWASP/Nest#5338: Modifies the same ActivityEvent integration points in GitHub synchronization and the activity event model.

Suggested reviewers: arkid15r

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Docker Compose volume changes are unrelated to Pulse activity-event GraphQL queries and appear outside the linked issue scope. Remove the unrelated Docker Compose volume changes or link an issue that requires them.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds paginated and recent activity-event GraphQL queries with filtering and ordering, satisfying issue #4672.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly describes the main change: adding GraphQL queries for OWASP Pulse activity events.
Description check ✅ Passed The description directly explains that the pull request adds GraphQL queries for OWASP Pulse activity events.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 375041e and 92c3dfa.

📒 Files selected for processing (11)
  • backend/src/apps/github/common.py
  • backend/src/apps/owasp/admin/__init__.py
  • backend/src/apps/owasp/admin/activity_event.py
  • backend/src/apps/owasp/api/internal/nodes/activity_event.py
  • backend/src/apps/owasp/api/internal/queries/__init__.py
  • backend/src/apps/owasp/api/internal/queries/activity_event.py
  • backend/src/apps/owasp/migrations/0073_activityevent.py
  • backend/src/apps/owasp/models/__init__.py
  • backend/src/apps/owasp/models/activity_event.py
  • backend/tests/unit/apps/github/common_test.py
  • docker-compose/local/compose.override.yaml

Comment thread backend/src/apps/github/common.py
Comment thread backend/src/apps/github/common.py
Comment thread backend/src/apps/owasp/api/internal/queries/activity_event.py Outdated
Comment thread backend/src/apps/owasp/models/activity_event.py
Comment thread backend/src/apps/owasp/models/activity_event.py
Comment thread backend/tests/unit/apps/github/common_test.py
Comment thread docker-compose/local/compose.override.yaml

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/src/apps/owasp/migrations/0073_activityevent.py
Comment thread backend/src/apps/github/common.py
Comment thread backend/src/apps/owasp/api/internal/queries/__init__.py
Comment thread backend/src/apps/owasp/models/activity_event.py
Comment thread backend/src/apps/owasp/models/activity_event.py
Comment thread backend/src/apps/owasp/api/internal/queries/activity_event.py Outdated
Comment thread docker-compose/local/compose.override.yaml
Comment thread backend/src/apps/github/common.py
Comment thread backend/src/apps/github/common.py
Comment thread backend/src/apps/github/common.py
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Contribution validation failed:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 92c3dfa and 6e710e8.

📒 Files selected for processing (2)
  • backend/src/apps/owasp/api/internal/queries/activity_event.py
  • backend/src/apps/owasp/models/activity_event.py

Comment thread backend/src/apps/owasp/api/internal/queries/activity_event.py Outdated
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.52273% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.42%. Comparing base (c305ad6) to head (2b118a4).
⚠️ Report is 1 commits behind head on feature/owasp-pulse.

Files with missing lines Patch % Lines
backend/src/apps/owasp/models/activity_event.py 58.88% 37 Missing ⚠️
.../apps/owasp/api/internal/queries/activity_event.py 32.60% 31 Missing ⚠️
...rc/apps/owasp/api/internal/nodes/activity_event.py 81.48% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   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              
Flag Coverage Δ
backend 98.81% <58.52%> (-0.57%) ⬇️
frontend 97.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/src/apps/github/common.py 100.00% <100.00%> (ø)
backend/src/apps/owasp/admin/activity_event.py 100.00% <100.00%> (ø)
...rc/apps/owasp/api/internal/nodes/activity_event.py 81.48% <81.48%> (ø)
.../apps/owasp/api/internal/queries/activity_event.py 32.60% <32.60%> (ø)
backend/src/apps/owasp/models/activity_event.py 58.88% <58.88%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b2c02f...2b118a4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Contribution validation failed:

@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@anurag2787
anurag2787 marked this pull request as ready for review August 8, 2026 18:15
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Contribution validation failed:

2 similar comments
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Contribution validation failed:

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Contribution validation failed:

@anurag2787 anurag2787 added the gsoc2026:anurag2787 anurag2787's GSoC 2026 related work label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend backend-tests gsoc2026:anurag2787 anurag2787's GSoC 2026 related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Pulse GraphQL Queries

1 participant