Skip to content

feat: add is_extended_promotional filterable column to components#322

Open
VOVANQUOCBAO wants to merge 1 commit into
tscircuit:mainfrom
VOVANQUOCBAO:fix/issue-92
Open

feat: add is_extended_promotional filterable column to components#322
VOVANQUOCBAO wants to merge 1 commit into
tscircuit:mainfrom
VOVANQUOCBAO:fix/issue-92

Conversation

@VOVANQUOCBAO
Copy link
Copy Markdown

Summary

Closes #92

Extended promotional parts on JLCPCB temporarily act as basic parts (no assembly surcharge), but currently the data has no way to identify them separately from permanent basic parts. The source database encodes this with basic = 2 (vs basic = 1 for regular basic, basic = 0 for extended).

This PR adds is_extended_promotional as a filterable boolean column to the component search API and UI.

Changes

  • lib/db/derivedtables/component-base.ts — adds is_extended_promotional: boolean to BaseComponent interface
  • lib/db/derivedtables/resistor.ts — adds is_extended_promotional to extraColumns and maps c.basic === 2
  • lib/db/derivedtables/capacitor.ts — same as resistor
  • lib/db/generated/kysely.ts — adds is_extended_promotional to generated Resistor and Capacitor interfaces (run bun run generate:db-types after rebuilding derived tables)
  • routes/resistors/list.tsx — adds is_extended_promotional query param, filter, JSON field, and UI checkbox
  • routes/capacitors/list.tsx — same as resistors route
  • routes/components/list.tsx — adds is_extended_promotional filter (basic = 2) and JSON field

Acceptance Criteria

  • is_extended_promotional is available as a filterable column in resistor and capacitor search routes
  • is_extended_promotional is available in the generic /components/list route
  • Existing is_basic behavior is unchanged (extended promotional parts with basic=2 still appear when filtering is_basic=true)
  • UI checkboxes added to resistor, capacitor, and components list pages
  • JSON API responses include is_extended_promotional field

Testing

  • Added tests/lib/extended-promotional.test.ts with 8 unit tests covering:
    • basic=0is_extended_promotional=false
    • basic=1is_extended_promotional=false
    • basic=2is_extended_promotional=true
    • basic=2 still gives is_basic=true (acts as basic per issue description)
    • Tests cover both resistor and capacitor table specs
  • Extended route test in tests/routes/resistors/list.test.ts to verify is_extended_promotional field appears in API response and filter works

All 18 existing lib tests pass. All 8 new tests pass.

Notes for other derived tables

The same 3-line pattern (add to extraColumns, set is_extended_promotional: c.basic === 2 in mapToTable, update route) can be applied to all remaining derived table specs (leds, microcontrollers, etc.) following the same pattern established here.


This PR was created with AI assistance (Claude).

Extended promotional parts act as basic for a limited time (basic=2 in
the source database). Expose this as a filterable boolean column on
resistor and capacitor tables, and in the generic components search.

- Add is_extended_promotional to BaseComponent interface
- Map c.basic === 2 in resistor and capacitor table specs
- Update generated Kysely types for Resistor and Capacitor
- Add is_extended_promotional filter and UI checkbox to /resistors/list,
  /capacitors/list, and /components/list routes
- Add 8 unit tests covering resistor and capacitor mapToTable behavior
- Add route test verifying is_extended_promotional filter works end-to-end

Closes tscircuit#92
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.

Add is_extended_promotional column to components (from data source)

1 participant