Skip to content

Order status updates + history (backend) — #41, #42#100

Merged
npcjake merged 2 commits into
mainfrom
order-status-history
Jun 2, 2026
Merged

Order status updates + history (backend) — #41, #42#100
npcjake merged 2 commits into
mainfrom
order-status-history

Conversation

@npcjake
Copy link
Copy Markdown
Contributor

@npcjake npcjake commented Jun 2, 2026

What & why

Implements the backend for #41 Get Order Status and #42 View Order History.

closes #41 and #42

The GET /api/orders/{id} and GET /api/orders?customerId= endpoints already
landed on main (via #81) but were untested, and the core of #41status
updates when the Order Service receives bot update events
— did not exist:
order status was set once at placement and never advanced.

Changes

  • Status consumer (Get Order Status #41): new OrderStatusConsumer BackgroundService reads bot
    events from the simulator's robot-output hub and advances order status:
    • RobotOrderAssignmentResponse: Accepted→InTransit, Queued→Assigned, Rejected→Failed
    • RobotStatusUpdated: OnDelivery→InTransit, DeliveryCompleted→Delivered
    • RobotDeliveryCompleted→Delivered
    • Pure, forward-only mapping so duplicate/out-of-order events can't regress status.
    • Correlates by the order GUID we already emit in RobotOrderAssignment. Verified
      against the merged simulator source that it echoes that id back in
      data.orderId/activeOrderId/previousOrderId.
    • Idle-with-warning when unconfigured, so the API still runs locally/in tests.
  • Tests: +22 unit tests (suite 10→32, all green) covering the read paths, the
    pure event→status mapping, and persisted status transitions.
  • IaC (Iac/order-service): dedicated order-service consumer group on
    robot-output + StatusConsumer__* env vars, reusing the existing namespace-level
    eventhub-connection-string secret (confirmed it has Listen on the namespace — no
    new secret or role assignment needed). terraform validate passes.

Frontend — out of scope (note)

The "on site" part of the acceptance criteria (#41 query-by-id, #42 view-history) needs
UI in the customer-webapp, which is crawfordkid2's area. It is intentionally
not in this PR to avoid stepping on that work. Meanwhile both endpoints are
exercisable via Swagger (enabled in all environments). The two pages
(Track Order, Order History) should be added by the frontend owner as a follow-up.

Already done outside this diff

  • SQL grant: the app's managed identity (deliverybot-order-service) was created as
    a DB user + added to db_owner on OrderServiceDb / jacob-orderservice-sql2

Refs #41, #42

…41, #42)

#41 Get Order Status: status previously never advanced past placement. Add an
Event Hub BackgroundService (OrderStatusConsumer) that reads bot events from the
simulator's robot-output hub and advances order status:
  - RobotOrderAssignmentResponse: Accepted->InTransit, Queued->Assigned, Rejected->Failed
  - RobotStatusUpdated: OnDelivery->InTransit, DeliveryCompleted->Delivered
  - RobotDeliveryCompleted->Delivered
Mapping is a pure, forward-only function (out-of-order/duplicate events can't
regress status). Correlates by the order GUID we emit in RobotOrderAssignment;
verified against the merged simulator source that it echoes that id back.
Idle-with-warning when StatusConsumer config is absent so the API still runs.

#41/#42 read endpoints (GetOrder, GetOrderHistory) already existed but were
untested; add 22 unit tests covering the read paths, the pure status mapping,
and persisted status transitions.

IaC (Iac/order-service): dedicated 'order-service' consumer group on robot-output
+ StatusConsumer env vars, reusing the namespace-level eventhub-connection-string
secret (has Listen on robot-output). terraform validate passes.
@npcjake npcjake requested a review from a team June 2, 2026 20:42
Orders were rejected by the simulator ('Item beverage is not stocked by this
bot') because OrderService emitted abstract item ids (food/beverage/package)
while the simulated bots stock water/soda/chips/sandwich (RobotSimulator
BotFleet). Map order options directly to the simulator catalog instead; default
unrecognized values to water (always stocked) so orders aren't rejected.

Verified live against the deployed simulator: it echoes our order GUID back in
RobotOrderAssignmentResponse, confirming the status-consumer correlation.

Note: this is Place Order (#40) contract logic, folded into this PR per request.
Frontend dropdown (customer-webapp, crawfordkid2) still lists the old types and
should be updated to water/soda/chips/sandwich as a follow-up.
Copy link
Copy Markdown
Contributor

@philspokas philspokas left a comment

Choose a reason for hiding this comment

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

lgtm

@npcjake npcjake merged commit 9aa5c15 into main Jun 2, 2026
2 checks passed
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.

Get Order Status

2 participants