Skip to content

Conversation

Copy link

Copilot AI commented Dec 19, 2025

Implements POST /partner_request/{type} for creating partner requests with dual-table insertion, removes next_status endpoint, and makes publish/cancel operations idempotent.

Changes

Create endpoint (POST /partner_request/{type})

  • Discriminated union schema validates request by type field (ride_hailing, commute)
  • Manager create() methods atomically insert base PartnerRequest + type-specific content table
  • Transaction rollback on failure
# Request body discriminated by type field
{
  "type": "ride_hailing",
  "title": "...",
  "route": [...],
  "ride_hailing_preference": {...}
}

Idempotent publish/cancel

  • PUT /partner_request/{pr_id}/publish - returns existing if already JOINABLE
  • PUT /partner_request/{pr_id}/cancel - returns existing if already CANCELLED
  • Applied to both route handlers and manager methods

Removed

  • PUT /partner_request/{pr_id}/status/next endpoint

Files Changed

  • main/schemas/partner_request/trip/create.py - Request schemas with discriminated union
  • main/managers/partner_request/trip/{ride_hailing,commute}.py - Implemented create() with dual-table insertion
  • main/managers/partner_request/base.py - Idempotent publish/cancel in managers
  • main/routes.py - New create endpoint, removed next_status, idempotent handlers
  • tests/test_pr/test_create_pr.py - Test coverage for all changes
Original prompt

Add create PartnerRequest endpoint.
Notes:

  • PartnerRequest has a varieity of types, each type has their own content table. Which means create a PartnerRequest will insert a row both in base table and the type-specific content table. This is already implemented in specific PartnerRequest manager like RideHailingPRManager, CommutePRManager (but still requires some adjustion).
  • the endpoints should be POST /partner_request/{type}
  • Add test unit for the endpoint

And by the way:

  • remove next_status endpoint
  • make publish_partner_request, cancel_partner_request idempotent (if status match the target status)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits December 19, 2025 04:29
…mpotent

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
… types

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
…ssages

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Copilot AI changed the title [WIP] Add create PartnerRequest endpoint and unit tests Add create endpoint for PartnerRequest and make publish/cancel idempotent Dec 19, 2025
Copilot AI requested a review from xiaoland December 19, 2025 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants