Skip to content

feat(freelancer-discovery): DB-backed API for issue #121#139

Merged
SudiptaPaul-31 merged 1 commit into
Lumina-eX:mainfrom
iyanumajekodunmi756:feat/freelancer-discovery-api-121
Jun 27, 2026
Merged

feat(freelancer-discovery): DB-backed API for issue #121#139
SudiptaPaul-31 merged 1 commit into
Lumina-eX:mainfrom
iyanumajekodunmi756:feat/freelancer-discovery-api-121

Conversation

@iyanumajekodunmi756

Copy link
Copy Markdown
Contributor

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:

  • 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.

closes #121

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.
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@SudiptaPaul-31 SudiptaPaul-31 merged commit 28bf585 into Lumina-eX:main Jun 27, 2026
1 check 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.

[Feature]: Freelancer Discovery API

2 participants