feat: Implement search and filtering system for listings#22
Conversation
|
@cole-hackman it looks like a few of your commits from the auth branch landed here, could you drop |
- Add condition field to listings (new, like_new, good, fair, poor) - Add searchAndFilterListings query with full-text search - Support category, price range, condition filters - Add sort options and cursor-based pagination (20 items/page) - Add compound indexes for performance
c78ca72 to
d6c883e
Compare
📝 WalkthroughWalkthroughA new advanced search and filtering API is introduced for listings, supporting full-text search, multi-field filtering by category, price, condition, and status, with sorting and cursor-based pagination. Schema indices are updated to support efficient queries, type definitions are expanded with filter options and listing properties, and validators are extracted for reuse. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Convex as Convex Backend
participant DB as Database
Client->>Convex: searchAndFilterListings(searchTerm?, filters, cursor?)
alt Has search term
Convex->>DB: Query search_listings index with searchTerm
DB-->>Convex: Matching documents
else No search term
Convex->>DB: Query by_status_category or by_status_createdAt
DB-->>Convex: Documents by index
end
Convex->>Convex: Apply in-memory filters (condition, price)
Convex->>Convex: Sort results (sortBy option)
Convex->>Convex: Apply cursor-based pagination
Convex-->>Client: { items[], nextCursor, hasMore }
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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. Comment |
|
@evan-taylor I dropped the other commits so it should be good now. Let me know if there is still issues, thanks |
Linked Issues
Closes #POLY-9
Linear: POLY-9
Summary
Implements search and filtering system for listings so buyers can quickly find items by keywords, category, price range, and condition.
Changes Made
Shared Types (
packages/shared/types/)filters.ts- Filter types:ListingFilters,ListingSortOption,PaginatedResult<T>listing.ts- AddedListingConditiontype andconditionfield toListingBackend (
backend/convex/)schema.ts:conditionfield (new, like_new, good, fair, poor)by_status_category,by_status_createdAtlistings.ts:searchAndFilterListingsquery with full-text search, filters, sorting, and paginationcreateListingto requireconditionfieldschema.test.ts- Updated tests for new fields and indexesFeatures
How to Test