feat: add is_extended_promotional column to components (#92)#130
feat: add is_extended_promotional column to components (#92)#130Yeachan-Heo wants to merge 1 commit intotscircuit:mainfrom
Conversation
…it#92) Add support for tracking extended promotional JLCPCB parts that temporarily act as basic parts. This adds: - is_extended_promotional column to components table via DB optimization - Column added to Component and VComponent types in generated kysely types - Filterable via is_extended_promotional query param on /components/list and /api/search routes - Filter checkbox in the components list UI - Index on the new column for query performance - v_components view recreation to include the new column - Tests for the new field and filter functionality Co-Authored-By: Claude Opus 4.6 <[email protected]>
| test("GET /api/search returns is_extended_promotional field", async () => { | ||
| const { axios } = await getTestServer() | ||
| const res = await axios.get("/api/search?q=resistor&limit=1") | ||
|
|
||
| expect(res.data).toHaveProperty("components") | ||
| expect(Array.isArray(res.data.components)).toBe(true) | ||
|
|
||
| if (res.data.components.length > 0) { | ||
| const component = res.data.components[0] | ||
| expect(component).toHaveProperty("is_extended_promotional") | ||
| expect(typeof component.is_extended_promotional).toBe("boolean") | ||
| } | ||
| }) | ||
|
|
||
| test("GET /api/search with is_extended_promotional filter", async () => { | ||
| const { axios } = await getTestServer() | ||
| const res = await axios.get("/api/search?is_extended_promotional=true") | ||
|
|
||
| expect(res.data).toHaveProperty("components") | ||
| expect(Array.isArray(res.data.components)).toBe(true) | ||
| }) |
There was a problem hiding this comment.
This test file violates the rule that a *.test.ts file may have AT MOST one test(...) function. The file now contains multiple test() functions (the original tests plus the two new ones added in lines 82-94 and 96-102). The file should be split into multiple numbered files like search1.test.ts, search2.test.ts, etc., with each file containing only one test() function.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
| test("GET /components/list returns is_extended_promotional field", async () => { | ||
| const { axios } = await getTestServer() | ||
| const res = await axios.get("/components/list?json=true") | ||
| expect(res.data).toHaveProperty("components") | ||
| expect(Array.isArray(res.data.components)).toBe(true) | ||
|
|
||
| if (res.data.components.length > 0) { | ||
| const component = res.data.components[0] | ||
| expect(component).toHaveProperty("is_extended_promotional") | ||
| expect(typeof component.is_extended_promotional).toBe("boolean") | ||
| } | ||
| }) | ||
|
|
||
| test("GET /components/list with is_extended_promotional filter", async () => { | ||
| const { axios } = await getTestServer() | ||
| const res = await axios.get( | ||
| "/components/list?json=true&is_extended_promotional=true", | ||
| ) | ||
| expect(res.data).toHaveProperty("components") | ||
| expect(Array.isArray(res.data.components)).toBe(true) | ||
| }) |
There was a problem hiding this comment.
This test file violates the rule that a *.test.ts file may have AT MOST one test(...) function. The file now contains multiple test() functions (the original test plus the two new ones added in lines 11-22 and 24-31). The file should be split into multiple numbered files like list1.test.ts, list2.test.ts, etc., with each file containing only one test() function.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
Summary
is_extended_promotional(integer 0/1) column to thecomponentstable to track JLCPCB parts that are temporarily promoted from extended to basic pricingALTER TABLE, creates an index, and recreates thev_componentsview to include itis_extended_promotionalas a filterable boolean query parameter on both/components/listand/api/searchroutesComponentandVComponentinterfaces in generated Kysely typesChanges
lib/db/generated/kysely.tsis_extended_promotionaltoComponentandVComponentinterfaceslib/db/optimizations/component-extended-promotional.tsv_componentsviewscripts/setup-db-optimizations.tsroutes/components/list.tsxroutes/api/search.tsxtests/routes/components/list.test.tstests/routes/api/search.test.tsTest plan
is_extended_promotionalfield appears in API responses as boolean?is_extended_promotional=truefilter returns only promotional componentsCloses #92
🤖 Generated with Claude Code