feat: add is_extended_promotional filterable column to components#322
Open
VOVANQUOCBAO wants to merge 1 commit into
Open
feat: add is_extended_promotional filterable column to components#322VOVANQUOCBAO wants to merge 1 commit into
VOVANQUOCBAO wants to merge 1 commit into
Conversation
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
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.
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(vsbasic = 1for regular basic,basic = 0for extended).This PR adds
is_extended_promotionalas a filterable boolean column to the component search API and UI.Changes
lib/db/derivedtables/component-base.ts— addsis_extended_promotional: booleantoBaseComponentinterfacelib/db/derivedtables/resistor.ts— addsis_extended_promotionaltoextraColumnsand mapsc.basic === 2lib/db/derivedtables/capacitor.ts— same as resistorlib/db/generated/kysely.ts— addsis_extended_promotionalto generatedResistorandCapacitorinterfaces (runbun run generate:db-typesafter rebuilding derived tables)routes/resistors/list.tsx— addsis_extended_promotionalquery param, filter, JSON field, and UI checkboxroutes/capacitors/list.tsx— same as resistors routeroutes/components/list.tsx— addsis_extended_promotionalfilter (basic = 2) and JSON fieldAcceptance Criteria
is_extended_promotionalis available as a filterable column in resistor and capacitor search routesis_extended_promotionalis available in the generic/components/listrouteis_basicbehavior is unchanged (extended promotional parts withbasic=2still appear when filteringis_basic=true)is_extended_promotionalfieldTesting
tests/lib/extended-promotional.test.tswith 8 unit tests covering:basic=0→is_extended_promotional=falsebasic=1→is_extended_promotional=falsebasic=2→is_extended_promotional=truebasic=2still givesis_basic=true(acts as basic per issue description)tests/routes/resistors/list.test.tsto verifyis_extended_promotionalfield appears in API response and filter worksAll 18 existing lib tests pass. All 8 new tests pass.
Notes for other derived tables
The same 3-line pattern (add to
extraColumns, setis_extended_promotional: c.basic === 2inmapToTable, 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).