feat(freelancer-discovery): DB-backed API for issue #121#139
Merged
SudiptaPaul-31 merged 1 commit intoJun 27, 2026
Merged
Conversation
Implements the Freelancer Discovery API described in Lumina-eX#121: GET /api/freelancers ?q=<text>&skills=react,nodejs&minRating=4&page=2&limit=20 &sort=rating&order=desc GET /api/freelancers/<id> Highlights: * lib/freelancerDiscovery.ts encapsulates the SQL builder, pagination, sort/filter validation, and row -> API shape mapping. * Single-template WHERE fragment with `<null/0 IS 0 OR <pred>>` lets the query issue exactly one DB round-trip per request, with every value bound as a Postgres parameter (no runtime SQL interpolation of the sort column or column name). * ORDER BY is a fully-static switch on (sort, order) with literal ASC/DESC inlined per branch. * Backward compatible with the existing /freelancers page: legacy ?rating= alias accepted, response shape unchanged, ?skills accepts both repeating and comma-separated values. * Structured error responses ({error, code}) for invalid query params and downstream failures (400 / 503). * GET /api/freelancers/[id] returns { freelancer, reputation } with reputation loaded best-effort; null on lookup failure so the page still renders. * scripts/010-freelancer-discovery-indexes.sql adds a GIN index on users.skills (skill-overlap + ILIKE search), a btree on users.rating DESC, and a partial index on user_type IN (freelancer, both). * 22 unit tests covering parse, validation, list/detail happy paths, pagination, fallback COUNT, validation errors, and 503 on DB error.
|
@iyanumajekodunmi756 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the Freelancer Discovery API described in #121:
GET /api/freelancers
?q=&skills=react,nodejs&minRating=4&page=2&limit=20
&sort=rating&order=desc
GET /api/freelancers/
Highlights:
<null/0 IS 0 OR <pred>>lets the query issue exactly one DB round-trip per request, with every value bound as a Postgres parameter (no runtime SQL interpolation of the sort column or column name).closes #121