Skip to content

[SILO-1026] feat: add estimates external API endpoints#8664

Open
Saurabhkmr98 wants to merge 5 commits intopreviewfrom
feat-estimates_external_api
Open

[SILO-1026] feat: add estimates external API endpoints#8664
Saurabhkmr98 wants to merge 5 commits intopreviewfrom
feat-estimates_external_api

Conversation

@Saurabhkmr98
Copy link
Member

@Saurabhkmr98 Saurabhkmr98 commented Feb 26, 2026

Description

  • Added external APIs for Project Estimate and Estimate Points

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features

    • Added API endpoints to manage project estimates and estimate points (collection and item routes, bulk create).
    • Added Estimate serializer to support full record creation and updates.
    • Database now enforces two estimate types: categories and points.
  • Bug Fixes / Validation

    • Estimate point input now rejects empty submissions and limits value length to 20 characters.
  • Documentation

    • Expanded OpenAPI docs, examples, parameters, and decorators for estimate endpoints.

@makeplane
Copy link

makeplane bot commented Feb 26, 2026

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b6cbdd1-3567-43f6-a674-8d325b786e24

📥 Commits

Reviewing files that changed from the base of the PR and between a1c6afd and 719cd6d.

📒 Files selected for processing (1)
  • apps/api/plane/api/views/estimate.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/api/plane/api/views/estimate.py

📝 Walkthrough

Walkthrough

Adds an estimates feature: serializers (Estimate, EstimatePoint) with validation, three REST endpoints for project estimates and points, URL routing, a migration and model enum for estimate type choices, and OpenAPI parameters/examples/decorators.

Changes

Cohort / File(s) Summary
Serializers
apps/api/plane/api/serializers/__init__.py, apps/api/plane/api/serializers/estimate.py
Added EstimateSerializer (all fields, workspace/project/deleted_at read-only, create injects context). Expanded EstimatePointSerializer to fields="__all__", added validate (reject empty, max 20 chars), adjusted read-only fields.
API Views & Routing
apps/api/plane/api/views/estimate.py, apps/api/plane/api/urls/estimate.py
Added ProjectEstimateAPIEndpoint, EstimatePointListCreateAPIEndpoint, EstimatePointDetailAPIEndpoint and wired routes under workspaces/<slug>/projects/<project_id>/estimates/. Endpoints support create/get/patch/delete and bulk create for points.
Models & Migration
apps/api/plane/db/models/estimate.py, apps/api/plane/db/migrations/0121_alter_estimate_type.py
Introduced EstimateType TextChoices and constrained Estimate.type to choices with default; added migration altering type field accordingly.
OpenAPI utilities
apps/api/plane/utils/openapi/__init__.py, .../decorators.py, .../examples.py, .../parameters.py
Exported estimate_docs/estimate_point_docs, added ESTIMATE_ID_PARAMETER, request/response example constants and sample mappings for Estimate and EstimatePoint.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant API as API Endpoint
    participant Serializer
    participant DB as Database

    Client->>API: POST /workspaces/{slug}/projects/{id}/estimates
    API->>API: check existing estimate
    alt exists
        API-->>Client: 409 Conflict
    else
        API->>Serializer: validate payload (context: workspace, project)
        Serializer->>Serializer: inject workspace/project into data
        Serializer-->>API: validated data
        API->>DB: create Estimate
        DB-->>API: created Estimate
        API-->>Client: 201 Created + Estimate
    end

    Client->>API: POST /workspaces/{slug}/projects/{id}/estimates/{estimate_id}/points
    API->>API: ensure estimate exists
    alt missing
        API-->>Client: 404 Not Found
    else
        API->>Serializer: validate list of points (many=True)
        Serializer->>Serializer: validate each point (non-empty, max 20 chars)
        Serializer-->>API: validated points
        API->>DB: bulk_create EstimatePoint records
        DB-->>API: created points
        API-->>Client: 201 Created + points array
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • Prashant-Surya
  • sriramveeraghanta

Poem

🐰 I hopped through code with gentle paws,

New estimates, choices, and endpoint laws,
Points validated, bulk-created in rows,
OpenAPI lights where the schema glows,
Hop—now merge, and forward we go! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main objective: adding external API endpoints for estimates functionality.
Description check ✅ Passed Description covers the main feature and correctly selects the feature type, but lacks test scenarios and linked issue references.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-estimates_external_api

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.

@Saurabhkmr98 Saurabhkmr98 self-assigned this Feb 26, 2026
Base automatically changed from feat-project_metadata_api to preview March 2, 2026 20:03
@Saurabhkmr98 Saurabhkmr98 added 🔄migrations Contains Migration changes labels Mar 25, 2026
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

🧹 Nitpick comments (2)
apps/api/plane/utils/openapi/decorators.py (1)

299-310: Consider including ESTIMATE_ID_PARAMETER in defaults.

Since estimate point endpoints are always nested under an estimate (/estimates/<estimate_id>/estimate-points/), including ESTIMATE_ID_PARAMETER in the defaults would reduce boilerplate at call sites. However, this follows the existing pattern where nested decorators don't include parent IDs by default, so the current implementation is acceptable.

📝 Optional enhancement
+from .parameters import WORKSPACE_SLUG_PARAMETER, PROJECT_ID_PARAMETER, ESTIMATE_ID_PARAMETER
+
 def estimate_point_docs(**kwargs):
     """Decorator for estimate point-related endpoints"""
     defaults = {
         "tags": ["Estimate Points"],
-        "parameters": [WORKSPACE_SLUG_PARAMETER, PROJECT_ID_PARAMETER],
+        "parameters": [WORKSPACE_SLUG_PARAMETER, PROJECT_ID_PARAMETER, ESTIMATE_ID_PARAMETER],
         "responses": {
         },
     }
     return extend_schema(**_merge_schema_options(defaults, kwargs))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api/plane/utils/openapi/decorators.py` around lines 299 - 310, The
decorator estimate_point_docs currently sets defaults for tags and parameters
but omits ESTIMATE_ID_PARAMETER, causing callers to repeatedly add the parent
estimate ID; update the defaults dict in estimate_point_docs to include
ESTIMATE_ID_PARAMETER alongside WORKSPACE_SLUG_PARAMETER and
PROJECT_ID_PARAMETER so nested estimate-point endpoints automatically document
the parent estimate ID, keeping the rest of the defaults (tags and responses)
unchanged and using the existing _merge_schema_options/extend_schema flow.
apps/api/plane/utils/openapi/parameters.py (1)

499-505: Consider adding examples for consistency with other UUID parameters.

Other UUID path parameters in this file (e.g., PROJECT_ID_PARAMETER, CYCLE_ID_PARAMETER, MODULE_ID_PARAMETER) include examples with sample UUIDs and descriptions. Adding an example here would maintain consistency in OpenAPI documentation.

📝 Proposed fix
 ESTIMATE_ID_PARAMETER = OpenApiParameter(
     name="estimate_id",
     description="Estimate ID",
     required=True,
     type=OpenApiTypes.UUID,
     location=OpenApiParameter.PATH,
+    examples=[
+        OpenApiExample(
+            name="Example estimate ID",
+            value="550e8400-e29b-41d4-a716-446655440000",
+            description="A typical estimate UUID",
+        )
+    ],
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api/plane/utils/openapi/parameters.py` around lines 499 - 505, The
ESTIMATE_ID_PARAMETER OpenApiParameter is missing an examples entry; add an
examples argument similar to
PROJECT_ID_PARAMETER/CYCLE_ID_PARAMETER/MODULE_ID_PARAMETER using an
OpenApiExample with a sample UUID and a short description (e.g., "Sample
estimate id") so the path parameter documentation is consistent with other UUID
parameters; update the ESTIMATE_ID_PARAMETER definition to include
examples=[OpenApiExample(value="00000000-0000-0000-0000-000000000000",
description="Sample estimate id")] (or equivalent) ensuring imports are present
if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/api/plane/api/views/estimate.py`:
- Around line 47-69: The post method currently uses Project.objects.get(...) and
Workspace.objects.get(...), which raise exceptions and make the subsequent
if-not checks unreachable; replace both calls with
Project.objects.filter(id=project_id, workspace__slug=slug).first() and
Workspace.objects.filter(slug=slug).first() (matching the file's pattern), then
check for None and return the 404 Response as written; ensure you still obtain
workspace and project to pass into serializer_class when creating the estimate
and keep the existing project_estimate check/serializer flow unchanged.

---

Nitpick comments:
In `@apps/api/plane/utils/openapi/decorators.py`:
- Around line 299-310: The decorator estimate_point_docs currently sets defaults
for tags and parameters but omits ESTIMATE_ID_PARAMETER, causing callers to
repeatedly add the parent estimate ID; update the defaults dict in
estimate_point_docs to include ESTIMATE_ID_PARAMETER alongside
WORKSPACE_SLUG_PARAMETER and PROJECT_ID_PARAMETER so nested estimate-point
endpoints automatically document the parent estimate ID, keeping the rest of the
defaults (tags and responses) unchanged and using the existing
_merge_schema_options/extend_schema flow.

In `@apps/api/plane/utils/openapi/parameters.py`:
- Around line 499-505: The ESTIMATE_ID_PARAMETER OpenApiParameter is missing an
examples entry; add an examples argument similar to
PROJECT_ID_PARAMETER/CYCLE_ID_PARAMETER/MODULE_ID_PARAMETER using an
OpenApiExample with a sample UUID and a short description (e.g., "Sample
estimate id") so the path parameter documentation is consistent with other UUID
parameters; update the ESTIMATE_ID_PARAMETER definition to include
examples=[OpenApiExample(value="00000000-0000-0000-0000-000000000000",
description="Sample estimate id")] (or equivalent) ensuring imports are present
if needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91f23a0f-f0da-4be5-9a35-990c74be990a

📥 Commits

Reviewing files that changed from the base of the PR and between d94a269 and a1c6afd.

📒 Files selected for processing (10)
  • apps/api/plane/api/serializers/__init__.py
  • apps/api/plane/api/serializers/estimate.py
  • apps/api/plane/api/urls/estimate.py
  • apps/api/plane/api/views/estimate.py
  • apps/api/plane/db/migrations/0121_alter_estimate_type.py
  • apps/api/plane/db/models/estimate.py
  • apps/api/plane/utils/openapi/__init__.py
  • apps/api/plane/utils/openapi/decorators.py
  • apps/api/plane/utils/openapi/examples.py
  • apps/api/plane/utils/openapi/parameters.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔄migrations Contains Migration changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant