Skip to content

Add ActivityEvent model and builder - #5233

Open
anurag2787 wants to merge 12 commits into
OWASP:feature/owasp-pulsefrom
anurag2787:pulse-activityevent-model
Open

Add ActivityEvent model and builder#5233
anurag2787 wants to merge 12 commits into
OWASP:feature/owasp-pulsefrom
anurag2787:pulse-activityevent-model

Conversation

@anurag2787

@anurag2787 anurag2787 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Proposed change

Implements the ActivityEvent model and builder for OWASP Pulse

Resolves #5210

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

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Summary by CodeRabbit

  • New Features

    • Added activity tracking for newly synchronized GitHub issues, pull requests, and releases.
    • Activity records include event type, timestamps, repository, and related item details.
    • Prevented duplicate activity entries when synchronization runs repeatedly.
    • Added administrative tools for viewing, filtering, and searching recorded activity.
  • Chores

    • Improved persistent storage for local development environments.

Walkthrough

Adds the ActivityEvent model, migration, GitHub synchronization hooks, Django admin registration, package export, test mocking, and local Docker Compose volume mappings.

Changes

ActivityEvent model

Layer / File(s) Summary
ActivityEvent model contract and event persistence
backend/src/apps/owasp/models/activity_event.py, backend/src/apps/owasp/models/__init__.py
Defines event types, source relations, constraints, indexes, event builders, persistence helpers, and the package export.
ActivityEvent database migration
backend/src/apps/owasp/migrations/0073_activityevent.py
Creates the github_activity_events table with its fields, relations, indexes, and uniqueness constraint.
GitHub synchronization integration
backend/src/apps/github/common.py, backend/tests/unit/apps/github/common_test.py
Creates activity events while syncing issues, pull requests, and releases, and mocks the new dependency in unit-test setup.
Django admin integration
backend/src/apps/owasp/admin/activity_event.py, backend/src/apps/owasp/admin/__init__.py
Registers ActivityEvent with autocomplete, display, filtering, and search configuration.

Local Compose volume mappings

Layer / File(s) Summary
Local service volume configuration
docker-compose/local/compose.override.yaml
Defines six named volumes mapped to pulse-suffixed Docker volumes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • OWASP/Nest#4669 — The PR adds the ActivityEvent model and integrates event creation with GitHub issue, pull request, and release synchronization.

Possibly related PRs

  • OWASP/Nest#5338 — Directly overlaps on the ActivityEvent model, migration, admin setup, exports, and GitHub synchronization.
  • OWASP/Nest#5381 — Directly overlaps on the ActivityEvent model, migration, admin setup, exports, and GitHub synchronization.

Suggested reviewers: kasya, 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 additions are unrelated to the ActivityEvent model and builder objectives in issue #5210. Remove the unrelated Docker Compose volume changes or link them to a separate issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding the ActivityEvent model and builder.
Description check ✅ Passed The description directly states that the PR implements the ActivityEvent model and builder and links issue #5210.
Linked Issues check ✅ Passed The PR creates the ActivityEvent model, migration, builders, admin integration, and synchronization logic required by issue #5210.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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.

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@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: 2

🤖 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/models/activity_event.py`:
- Around line 22-31: The ActivityEvent model must allow repeated events for the
same object and activity type. In
backend/src/apps/github/models/activity_event.py lines 22-31, remove or redefine
the unique_activity_event constraint using an event-specific identifier or
occurred_at if uniqueness is still required; in
backend/src/apps/github/migrations/0045_activityevent.py line 32, update the
migration to match the model and remove the existing database constraint.

In `@docker-compose/local/compose.yaml`:
- Around line 124-135: Update cleanup targets in backend/Makefile,
docs/Makefile, and frontend/Makefile to remove the renamed -pulse volume names.
The volume definitions at docker-compose/local/compose.yaml lines 124-135 and
references at lines 26-27, 44-45, 80-81, and 102-103 require no direct changes;
use them as the authoritative names for the Makefile cleanup commands.
🪄 Autofix (Beta)

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

Run ID: 19e3c841-fdbf-4918-9af0-a1eed3d01b2a

📥 Commits

Reviewing files that changed from the base of the PR and between 2844bcc and b10a3f3.

📒 Files selected for processing (8)
  • backend/src/apps/github/admin/__init__.py
  • backend/src/apps/github/admin/activity_event.py
  • backend/src/apps/github/migrations/0045_activityevent.py
  • backend/src/apps/github/models/__init__.py
  • backend/src/apps/github/models/activity_event.py
  • backend/src/apps/github/models/enums/__init__.py
  • backend/src/apps/github/models/enums/activity_event.py
  • docker-compose/local/compose.yaml

Comment thread backend/src/apps/github/models/activity_event.py Outdated
Comment thread docker-compose/local/compose.yaml Outdated

@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 8 files

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

Re-trigger cubic

Comment thread docker-compose/local/compose.yaml Outdated
Comment thread backend/src/apps/github/models/activity_event.py Outdated
Comment thread docker-compose/local/compose.yaml Outdated
Comment thread backend/src/apps/github/migrations/0045_activityevent.py Outdated
Comment thread backend/src/apps/github/models/enums/activity_event.py Outdated
@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
backend/src/apps/github/models/activity_event.py (2)

51-70: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Prevent duplicate and redundant database indexes on ForeignKey fields.

Django automatically creates B-tree indexes for all ForeignKey fields.

  1. actor and repository: The Meta.indexes block explicitly defines custom indexes for these fields. This will result in duplicate standalone database indexes being created.
  2. content_type: The Meta.indexes block defines a composite index on ["content_type", "object_id"]. Since content_type is the leading column in this composite index, it can be used efficiently for queries filtering just by content_type. The implicit standalone index on content_type is therefore redundant.

To keep your explicit indexes while avoiding database write-penalty and wasted storage space from the implicit ones, explicitly disable db_index on these fields in both the model and the migration.

  • backend/src/apps/github/models/activity_event.py#L51-L70: Add db_index=False to the actor, content_type, and repository ForeignKey declarations.
  • backend/src/apps/github/migrations/0045_activityevent.py#L50-L74: Update the migration to reflect these constraints so the database tables are created cleanly without redundant indexes.
🚀 Proposed fix for the model (backend/src/apps/github/models/activity_event.py)
     actor = models.ForeignKey(
         "github.User",
         verbose_name="Actor",
         on_delete=models.SET_NULL,
         blank=True,
         null=True,
         related_name="activity_events",
+        db_index=False,
     )
-    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
+    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, db_index=False)
     object_id = models.PositiveBigIntegerField()
     occurred_at = models.DateTimeField(
         verbose_name="Occurred at",
         help_text="Timestamp when the activity event occurred on GitHub",
     )
     repository = models.ForeignKey(
         "github.Repository",
         verbose_name="Repository",
         on_delete=models.CASCADE,
         related_name="activity_events",
+        db_index=False,
     )
🚀 Proposed fix for the migration (backend/src/apps/github/migrations/0045_activityevent.py)
                 (
                     "actor",
                     models.ForeignKey(
                         blank=True,
                         null=True,
                         on_delete=django.db.models.deletion.SET_NULL,
                         related_name="activity_events",
                         to="github.user",
                         verbose_name="Actor",
+                        db_index=False,
                     ),
                 ),
                 (
                     "content_type",
                     models.ForeignKey(
-                        on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype"
+                        on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype", db_index=False
                     ),
                 ),
                 (
                     "repository",
                     models.ForeignKey(
                         on_delete=django.db.models.deletion.CASCADE,
                         related_name="activity_events",
                         to="github.repository",
                         verbose_name="Repository",
+                        db_index=False,
                     ),
                 ),
🤖 Prompt for 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.

In `@backend/src/apps/github/models/activity_event.py` around lines 51 - 70, Set
db_index=False on the actor, content_type, and repository ForeignKey
declarations in backend/src/apps/github/models/activity_event.py:51-70,
preserving the explicit indexes. Update the corresponding field definitions in
backend/src/apps/github/migrations/0045_activityevent.py:50-74 to include the
same db_index=False settings; both sites require direct changes.

73-75: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Handle nullable actor gracefully in string representation.

actor is a nullable foreign key. If an event has no actor, self.actor evaluates to None, resulting in a literal "None" in the string (e.g., "issue_closed by None in org/repo").

♻️ Proposed refactor
     def __str__(self) -> str:
         """Return human-readable representation."""
-        return f"{self.activity_type} by {self.actor} in {self.repository}"
+        actor_str = f" by {self.actor}" if self.actor else ""
+        return f"{self.activity_type}{actor_str} in {self.repository}"
🤖 Prompt for 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.

In `@backend/src/apps/github/models/activity_event.py` around lines 73 - 75,
Update ActivityEvent.__str__ to handle a null actor without rendering the
literal “None”; use an appropriate fallback or omit the actor portion while
preserving the existing activity type and repository information.
🤖 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.

Outside diff comments:
In `@backend/src/apps/github/models/activity_event.py`:
- Around line 51-70: Set db_index=False on the actor, content_type, and
repository ForeignKey declarations in
backend/src/apps/github/models/activity_event.py:51-70, preserving the explicit
indexes. Update the corresponding field definitions in
backend/src/apps/github/migrations/0045_activityevent.py:50-74 to include the
same db_index=False settings; both sites require direct changes.
- Around line 73-75: Update ActivityEvent.__str__ to handle a null actor without
rendering the literal “None”; use an appropriate fallback or omit the actor
portion while preserving the existing activity type and repository information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ee8269db-5ee8-43d7-b860-628acf72c21b

📥 Commits

Reviewing files that changed from the base of the PR and between b10a3f3 and dc695f5.

📒 Files selected for processing (3)
  • backend/src/apps/github/migrations/0045_activityevent.py
  • backend/src/apps/github/models/activity_event.py
  • backend/src/apps/github/models/enums/activity_event.py
💤 Files with no reviewable changes (1)
  • backend/src/apps/github/models/enums/activity_event.py

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 18, 2026
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.96552% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.68%. Comparing base (c305ad6) to head (023e9b4).
⚠️ Report is 1 commits behind head on feature/owasp-pulse.

Files with missing lines Patch % Lines
backend/src/apps/owasp/models/activity_event.py 60.29% 27 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##           feature/owasp-pulse    #5233      +/-   ##
=======================================================
- Coverage                98.83%   98.68%   -0.16%     
=======================================================
  Files                      538      540       +2     
  Lines                    17123    17209      +86     
  Branches                  2460     2466       +6     
=======================================================
+ Hits                     16924    16983      +59     
- Misses                      99      126      +27     
  Partials                   100      100              
Flag Coverage Δ
backend 99.16% <68.96%> (-0.21%) ⬇️
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%> (ø)
backend/src/apps/owasp/models/activity_event.py 60.29% <60.29%> (ø)

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...023e9b4. 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 3 files (changes from recent commits).

Requires human review: Auto-approval blocked by 2 unresolved issues from previous reviews.

Re-trigger cubic

@anurag2787
anurag2787 marked this pull request as ready for review July 18, 2026 17:30
@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

4 similar comments
@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

  • commit_sign_off: One or more commits are missing or have an invalid Signed-off-by trailer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This belongs to owasp application, not github.

from django.db import models


class ActivityType(models.TextChoices):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason for not following existing examples and making it part of ActivityEvent model?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

earlier i was planning to keep ActivityEventBuilder outside the module which is why i introduced a separate enum but as you suggested i will keep ActivityType inside the ActivityEvent model and will move the builder into the module itself

max_length=32,
choices=ActivityType.choices,
)
actor = models.ForeignKey(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
actor = models.ForeignKey(
github_user = models.ForeignKey(

verbose_name="Occurred at",
help_text="Timestamp when the activity event occurred on GitHub",
)
repository = models.ForeignKey(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
repository = models.ForeignKey(
github_repository = models.ForeignKey(

Comment thread docker-compose/local/compose.yaml Outdated
volumes:
- ../../backend:/home/owasp
- backend-venv:/home/owasp/.venv
- backend-venv-pulse:/home/owasp/.venv

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We now use override approach, please update and help testing that.

@github-actions

Copy link
Copy Markdown

Contribution validation failed:

1 similar comment
@github-actions

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: 4

🤖 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/admin/activity_event.py`:
- Line 8: Register the ActivityEvent model with Django admin using the existing
ActivityEventAdmin class so Activity Events appear in the admin interface.
Locate the model registration alongside the ActivityEventAdmin definition and
preserve its current configuration.

In `@backend/src/apps/owasp/migrations/0073_activityevent.py`:
- Around line 1-36: Reformat the generated Migration class in
0073_activityevent.py with Ruff’s formatter, preserving the migration
operations, dependencies, indexes, and constraints unchanged; commit the
formatter’s output so pre-commit passes.
- Around line 15-36: Update migration 0073 after creating ActivityEvent to
backfill existing Issue, PullRequest, and Release records into the new table,
using an idempotent RunPython operation and the migration app registry for
historical models. Reuse the same activity types, timestamps, repository/user
relationships, and content-type/object-id mapping expected by ActivityEvent,
while safely avoiding duplicate rows on repeated deployment or migration
execution.

In `@backend/src/apps/owasp/models/activity_event.py`:
- Line 134: Update the exception path in the model conversion method containing
the “Unsupported model type” message: assign the formatted error text to a local
variable before raising TypeError, so the raise statement uses the prebuilt
message and satisfies Ruff EM102 and TRY003.
🪄 Autofix (Beta)

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: 524f13bf-1dff-4fe8-94b1-dcaa32f75f13

📥 Commits

Reviewing files that changed from the base of the PR and between dc695f5 and 2004c75.

📒 Files selected for processing (7)
  • 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/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

Comment thread backend/src/apps/owasp/admin/activity_event.py
Comment thread backend/src/apps/owasp/migrations/0073_activityevent.py
Comment thread backend/src/apps/owasp/migrations/0073_activityevent.py
Comment thread backend/src/apps/owasp/models/activity_event.py Outdated
@github-actions

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose/local/compose.yaml (1)

128-133: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Declare the renamed volumes consistently.

The service mounts now use backend-venv-pulse, cache-data-pulse, frontend-next-pulse, and frontend-node-modules-pulse, but these top-level declarations still use the old names. Docker Compose will treat the new service references as undefined volumes. Rename the corresponding declarations here, and update CANONICAL_VOLUMES in .github/scripts/docker_compose_check.py plus TEST_ALLOWED_VOLUMES in tools/tests/github/scripts/docker_compose_check_test.py.

Proposed fix
-  backend-venv:
-  cache-data:
+  backend-venv-pulse:
+  cache-data-pulse:
   db-data:
   docs-venv:
-  frontend-next:
-  frontend-node-modules:
+  frontend-next-pulse:
+  frontend-node-modules-pulse:
🤖 Prompt for 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.

In `@docker-compose/local/compose.yaml` around lines 128 - 133, Rename the
corresponding top-level volume declarations from backend-venv, cache-data,
frontend-next, and frontend-node-modules to their -pulse names in the compose
configuration, then update CANONICAL_VOLUMES and TEST_ALLOWED_VOLUMES to use the
same renamed volume identifiers.
🤖 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.

Outside diff comments:
In `@docker-compose/local/compose.yaml`:
- Around line 128-133: Rename the corresponding top-level volume declarations
from backend-venv, cache-data, frontend-next, and frontend-node-modules to their
-pulse names in the compose configuration, then update CANONICAL_VOLUMES and
TEST_ALLOWED_VOLUMES to use the same renamed volume identifiers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0400b4f2-d064-49a5-940b-abd11310cba7

📥 Commits

Reviewing files that changed from the base of the PR and between 2004c75 and fda1f30.

📒 Files selected for processing (1)
  • docker-compose/local/compose.yaml

@github-actions

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 `@docker-compose/local/compose.override.yaml`:
- Around line 1-13: Remove the committed custom name mappings for backend-venv,
cache-data, db-data, docs-venv, frontend-next, and frontend-node-modules in the
compose override, restoring the file to its documented empty in-tree state. Do
not retain any *-pulse volume names unless the same change also updates the
canonical-volume checker and documented policy.
🪄 Autofix (Beta)

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: 35c01dc0-4903-42fb-b0f7-101a4c17a5c0

📥 Commits

Reviewing files that changed from the base of the PR and between fda1f30 and ae10e4f.

📒 Files selected for processing (3)
  • backend/src/apps/owasp/migrations/0073_activityevent.py
  • backend/src/apps/owasp/models/activity_event.py
  • docker-compose/local/compose.override.yaml

Comment thread docker-compose/local/compose.override.yaml
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Jul 29, 2026

@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 4 files (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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 29, 2026
anurag2787 and others added 3 commits August 9, 2026 10:41
Signed-off-by: Anurag Yadav <143180737+anurag2787@users.noreply.github.com>
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@anurag2787
anurag2787 force-pushed the pulse-activityevent-model branch from cc0f1de to 5244db5 Compare August 9, 2026 05:12
@anurag2787

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review it again

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@anurag2787 I will review the current changes in #5233.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@anurag2787

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review again

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review again

@anurag2787 I have started the AI code review. It will take a few minutes to complete.

@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/models/activity_event.py`:
- Around line 120-123: Update ActivityEvent.build_for_release to return no
events when release.published_at is None; only create RELEASE_PUBLISHED using
the actual published_at value. In the release synchronization flow in common.py,
adjust the existing-node early-break logic so previously synced unpublished
releases are revisited after GitHub publishes them.
🪄 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: 650884b5-df8e-4214-b720-39d0e099afa7

📥 Commits

Reviewing files that changed from the base of the PR and between fda1f30 and 5244db5.

📒 Files selected for processing (4)
  • backend/src/apps/owasp/admin/activity_event.py
  • backend/src/apps/owasp/migrations/0073_activityevent.py
  • backend/src/apps/owasp/models/activity_event.py
  • docker-compose/local/compose.override.yaml

Comment thread backend/src/apps/owasp/models/activity_event.py Outdated

@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 8 files

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

Re-trigger cubic

Comment thread backend/src/apps/github/common.py Outdated
Comment thread backend/src/apps/owasp/models/activity_event.py Outdated
Comment thread backend/src/apps/github/common.py Outdated
@cubic-dev-ai
cubic-dev-ai Bot dismissed their stale review August 9, 2026 05:52

Dismissed because Cubic found issues in a newer review.

Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>

@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 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread backend/src/apps/owasp/models/activity_event.py
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 9, 2026
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 9, 2026

@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 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread backend/src/apps/github/common.py Outdated
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 9, 2026
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Aug 9, 2026

@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

]

@staticmethod
def update_data(obj) -> list["ActivityEvent"]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you come up w/ a better naming here instead of obj.

"""Bulk-insert ActivityEvent rows for source objects, skipping duplicates."""
events = [event for obj in objects for event in ActivityEvent.update_data(obj)]
if events:
ActivityEvent.objects.bulk_create(events, ignore_conflicts=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do you need to ignore conflicts?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

since the sync can run multiple times so some events may already exist in that case we just want to skip them instead of getting an IntegrityError so because of that i added this

events = [(ActivityEvent.ActivityType.PR_OPENED, pr.created_at, pr.author)]
if pr.merged_at:
events.append((ActivityEvent.ActivityType.PR_MERGED, pr.merged_at, pr.author))
elif pr.state == "closed" and pr.closed_at:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't follow the approach consistently -- see IssueState

"""Bulk-insert ActivityEvent rows for source objects, skipping duplicates."""
events = [event for obj in objects for event in ActivityEvent.update_data(obj)]
if events:
ActivityEvent.objects.bulk_create(events, ignore_conflicts=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also why not using ActivityEvent.bulk_save?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I haven't use ActivityEvent.bulk_save because it doesn't ignore conflict since ActivityEvents are immutable so we only need to insert new ones and skip the ones that already exist

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why would you have a situation where you need to ignore conflicts, e.g. insert (re-insert) ones that already exist? We wan only new events as a source of data.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason is that the issue and PR sync is based on updated_at and not on whether an ActivityEvent already exists so when an issue or PR gets updated for example when a new comment is added it can get synced again and the same historical event can be generated again and since the ActivityEvents are immutable so because of tha unique constraint bulk_create would fail with an integrity error

Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@sonarqubecloud

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 2 files (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 requested a review from arkid15r August 12, 2026 16:36
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.

2 participants