Skip to content

feat: add is_extended_promotional column to components and search API#143

Open
Nicolas-Rozas wants to merge 4 commits intotscircuit:mainfrom
Nicolas-Rozas:feat/add-is-extended-promotional-92
Open

feat: add is_extended_promotional column to components and search API#143
Nicolas-Rozas wants to merge 4 commits intotscircuit:mainfrom
Nicolas-Rozas:feat/add-is-extended-promotional-92

Conversation

@Nicolas-Rozas
Copy link

Summary

Adds is_extended_promotional boolean field to the components list and search API endpoints, as requested in #92.

Extended promotional parts are those that temporarily act as basic parts — identified as preferred = 1 AND basic = 0.

Changes

routes/components/list.tsx

  • Added is_extended_promotional to queryParams schema
  • Added computed CASE WHEN preferred = 1 AND basic = 0 THEN 1 ELSE 0 END in SELECT
  • Added preferred column to SELECT (needed for the computed field)
  • Added filter: ?is_extended_promotional=true narrows results to extended promotional parts only
  • Added is_extended_promotional boolean to the component response map
  • Added "Extended Promotional" checkbox to the UI filter form

routes/api/search.tsx

  • Added is_extended_promotional to queryParams schema
  • Added filter: ?is_extended_promotional=true filters by preferred=1 AND basic=0
  • Added is_extended_promotional to the component response map (computed from preferred && !basic)

lib/db/derivedtables/component-base.ts

  • Added is_extended_promotional: boolean to BaseComponent interface

tests/routes/api/search.test.ts

  • Added test verifying is_extended_promotional field is present and is a boolean
  • Added test verifying filter returns only is_preferred=true, is_basic=false components

tests/routes/components/list.test.ts

  • Added test verifying is_extended_promotional field is present and is a boolean
  • Added test verifying filter returns only extended promotional components

/claim #92

- Add is_extended_promotional to queryParams in /components/list and /api/search
- Compute is_extended_promotional as CASE WHEN preferred=1 AND basic=0 THEN 1 ELSE 0 END
- Add filter support: ?is_extended_promotional=true filters to extended promotional parts
- Include is_extended_promotional in API response for both endpoints
- Add Extended Promotional checkbox to /components/list UI
- Update BaseComponent interface to include is_extended_promotional
- Add tests for is_extended_promotional field presence and filtering
@soongtv
Copy link

soongtv commented Mar 11, 2026

🎬 UI Demo

Demonstration of the **is_extend

bounty-92-ui-demo.mp4

ed_promotional** filter feature:

![is_extended_promotional UI Demo]

What the video shows:

  1. Navigating to the components list page
  2. Opening the filter panel
  3. Enabling the 'Extended Promotional' filter
  4. Viewing the filtered results (components where preferred=1 AND basic=0)

The implementation adds:

  • ✅ \is_extended_promotional\ computed field to both /components/list\ and /api/search\ endpoints
  • ✅ Filter parameter: ?is_extended_promotional=true\
  • ✅ UI checkbox for filtering
  • ✅ Test coverage for field presence and filter behavior

/claim #92

@Nicolas-Rozas
Copy link
Author

@seveibar Just set up GitHub Sponsors and connected Stripe — waiting for profile approval. All CI checks are passing and no conflicts. Could you review and merge when you get a chance? Thanks!

songshanhua-eng added a commit to songshanhua-eng/jlcsearch that referenced this pull request Mar 13, 2026
… tests

- Restore original search.test.ts and list.test.ts (no splitting)
- Restore original get-test-server.ts (no complex db validation)
- Restore original preload.ts (no complex db checks)
- Add is_extended_promotional field tests at end of existing test files
- Follow PR tscircuit#143 pattern for test structure

This simplifies the test setup and matches the pattern used in PR tscircuit#143
which successfully passed all CI tests.
songshanhua-eng added a commit to songshanhua-eng/jlcsearch that referenced this pull request Mar 13, 2026
- Change from .where((eb) => eb(...).and(...)) to .where().where()
- Match PR tscircuit#143 implementation that passed all tests
- Fix database query that was causing test failures

This fixes the incorrect Kysely query syntax that was causing
92/94 tests to pass but 2 tests to fail.
songshanhua-eng added a commit to songshanhua-eng/jlcsearch that referenced this pull request Mar 13, 2026
…void breaking component category tests

- Keep is_extended_promotional field in response (for UI display)
- Remove filtering logic (only available in /api/search endpoint)
- This matches PR tscircuit#143 pattern that passed all tests
- Component category list endpoints (resistors/list, etc.) inherit from this,
  so filtering would break their existing tests
songshanhua-eng added a commit to songshanhua-eng/jlcsearch that referenced this pull request Mar 13, 2026
- This test was failing because filtering is only available in /api/search
- Keep the field test (is_extended_promotional field exists in response)
- Remove the filter test (filtering logic removed from /components/list)
- This matches PR tscircuit#143 pattern that passed all tests
songshanhua-eng added a commit to songshanhua-eng/jlcsearch that referenced this pull request Mar 13, 2026
…scircuit#143 pattern

- Remove is_extended_promotional field from /components/list response
- Remove is_extended_promotional query parameter
- Remove related tests
- Keep is_extended_promotional only in /api/search endpoint
- This matches PR tscircuit#143 that passed all tests

The field was breaking component category list tests (resistors/list, etc.)
because those endpoints inherit from /components/list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants