Skip to content

Conversation

@rudransh-shrivastava
Copy link
Collaborator

@rudransh-shrivastava rudransh-shrivastava commented Nov 5, 2025

Resolves #2539

Proposed change

  • Extend Nest API with snapshot data.
  • Add tests.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Summary by CodeRabbit

  • New Features

    • Added Snapshot API endpoints for retrieving snapshot data with pagination and caching.
    • New endpoints to access snapshot details and related collections (chapters, issues, projects, releases, users).
    • Support for custom sorting options on snapshot data.
  • Tests

    • Added comprehensive test coverage for new Snapshot API functionality.

Walkthrough

Adds a new Snapshots API v0 module with list/detail endpoints and related-collection endpoints, registers the snapshot router, extends the Snapshot model with five read-only count properties, and adds unit tests updating the router expectations.

Changes

Cohort / File(s) Summary
API Router Registration
backend/apps/api/rest/v0/__init__.py
Imported snapshot_router and added "/snapshots": snapshot_router to the ROUTERS mapping.
Snapshot API Endpoints
backend/apps/api/rest/v0/snapshot.py
New REST module defining schemas (SnapshotBase, Snapshot, SnapshotDetail, SnapshotError) and endpoints: list_snapshots, get_snapshot, list_snapshot_chapters, list_snapshot_issues, list_snapshot_projects, list_snapshot_releases, list_snapshot_users. Endpoints use pagination, ordering, case-insensitive key lookup, cache_response, and return 404 with SnapshotError when not found.
Model Extensions
backend/apps/owasp/models/snapshot.py
Added read-only properties on Snapshot: new_chapters_count, new_issues_count, new_projects_count, new_releases_count, new_users_count returning counts of related objects.
Tests
backend/tests/apps/api/rest/v0/snapshot_test.py, backend/tests/apps/api/rest/v0/urls_test.py
New tests for snapshot schemas and API endpoints (mock-driven); updated URL/router tests to include the /snapshots router.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review backend/apps/api/rest/v0/snapshot.py for caching usage, pagination and ordering implementation, case-insensitive snapshot lookup, and consistent 404/error payloads.
  • Check backend/apps/owasp/models/snapshot.py for potential extra DB work (counts) and whether properties should be annotated or optimized to avoid N+1 issues.
  • Verify tests in backend/tests/... correctly mock ORM semantics and that router registration in backend/apps/api/rest/v0/init.py matches actual router export.

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: extending the Nest API with snapshot data, which aligns with the core modifications adding snapshot endpoints and models.
Linked Issues check ✅ Passed The changeset implements the primary objective from issue #2539 by adding snapshot API endpoints, models, schemas, and tests.
Out of Scope Changes check ✅ Passed All changes are directly related to extending the Nest API with snapshot functionality; no out-of-scope modifications detected.
Description check ✅ Passed The pull request description directly references the resolved issue (#2539) and clearly describes the proposed changes: extending the Nest API with snapshot data and adding tests.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f203c7c and 9391d76.

📒 Files selected for processing (3)
  • backend/apps/api/rest/v0/__init__.py (2 hunks)
  • backend/apps/api/rest/v0/snapshot.py (1 hunks)
  • backend/apps/owasp/models/snapshot.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
backend/apps/api/rest/v0/__init__.py (1)
backend/apps/owasp/api/internal/queries/snapshot.py (1)
  • snapshot (14-22)
backend/apps/owasp/models/snapshot.py (1)
backend/apps/owasp/api/internal/nodes/snapshot.py (5)
  • new_chapters (35-37)
  • new_issues (40-42)
  • new_projects (45-47)
  • new_releases (50-52)
  • new_users (55-57)
backend/apps/api/rest/v0/snapshot.py (2)
backend/apps/api/decorators/cache.py (1)
  • cache_response (19-56)
backend/apps/owasp/models/snapshot.py (7)
  • Snapshot (7-72)
  • Status (14-18)
  • new_chapters_count (50-52)
  • new_issues_count (55-57)
  • new_projects_count (60-62)
  • new_releases_count (65-67)
  • new_users_count (70-72)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run CI Denendencies Scan
  • GitHub Check: CodeQL (javascript-typescript)

@rudransh-shrivastava rudransh-shrivastava force-pushed the feature/nest-api-snapshot-endpoints branch from 9391d76 to 5644467 Compare November 5, 2025 14:52
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

@rudransh-shrivastava rudransh-shrivastava marked this pull request as ready for review November 5, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend Nest API with snapshot data

1 participant