feat: extend order listing with date range and sorting filters#57
Conversation
|
@GandrothuNagaSaiRishitha is attempting to deploy a commit to the Revon Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughExtended order listing with date range filtering and sorting capabilities; simplified environment validation by removing schema-based checks; enhanced server request handling with customizable response headers and parameter validation across orders endpoint. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant Database
Client->>Server: GET /api/orders?from=X&to=Y&sort=asc
Server->>Server: Validate date format & sort param
Server->>Server: Convert from/to to timestamps
Server->>Database: getOrders({spotId, userId, from, to, sort})
Database->>Database: Filter by created_at range
Database->>Database: Sort by created_at (asc/desc)
Database-->>Server: Return filtered & sorted orders
Server-->>Client: sendJson(res, 200, orders)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Closes #22
Extends the
GET /api/ordersendpoint to support date range filteringand sort order controls, as requested in the issue.
Changes Made
backend/server.jsfrom,to, andsortquery parameter extractionsortmust beascordesc→ returns400if invalidfromandtomust be valid ISO 8601 dates → returns400if invaliddatabase.getOrders()sendJsonfunctionbackend/db.jsgetOrders()to acceptfrom,to, andsortparametersfromfilters orders wherecreatedAt >= fromtofilters orders wherecreatedAt <= tosortcontrols ascending or descending order bycreatedAt(defaults todesc)backend/env.jsSyntaxErroron server startAcceptance Criteria
createdAtasc/descsortingAPI Usage
GET /api/ordersGET /api/orders?sort=ascGET /api/orders?from=2025-01-01&to=2025-12-31GET /api/orders?sort=randomGET /api/orders?from=not-a-dateScreenshots
1. GET /api/orders — All orders (default
sort=desc)2. GET /api/orders?sort=asc — Ascending sort
3. GET /api/orders?from=2025-01-01&to=2025-12-31 — Date range filter
4. GET /api/orders?sort=random — Validation error (400)
if feature found good and working, please merge this pr with relavant aperture 3.0 and difficulty labels
Summary by CodeRabbit
New Features
Bug Fixes
Refactor