Skip to content

feat: add is_extended_promotional column to components (#92)#130

Open
Yeachan-Heo wants to merge 1 commit intotscircuit:mainfrom
Yeachan-Heo:feat/add-is-extended-promotional-92
Open

feat: add is_extended_promotional column to components (#92)#130
Yeachan-Heo wants to merge 1 commit intotscircuit:mainfrom
Yeachan-Heo:feat/add-is-extended-promotional-92

Conversation

@Yeachan-Heo
Copy link

Summary

  • Adds is_extended_promotional (integer 0/1) column to the components table to track JLCPCB parts that are temporarily promoted from extended to basic pricing
  • Implements a DB optimization that adds the column via ALTER TABLE, creates an index, and recreates the v_components view to include it
  • Adds is_extended_promotional as a filterable boolean query parameter on both /components/list and /api/search routes
  • Includes filter checkbox in the components list HTML UI
  • Updates Component and VComponent interfaces in generated Kysely types

Changes

File Description
lib/db/generated/kysely.ts Added is_extended_promotional to Component and VComponent interfaces
lib/db/optimizations/component-extended-promotional.ts New optimization: adds column, index, and updates v_components view
scripts/setup-db-optimizations.ts Registered new optimization in the pipeline
routes/components/list.tsx Added query param, filter, response field, and UI checkbox
routes/api/search.tsx Added query param, filter, and response field
tests/routes/components/list.test.ts Tests for field presence and filter functionality
tests/routes/api/search.test.ts Tests for field presence and filter functionality

Test plan

  • Verified is_extended_promotional field appears in API responses as boolean
  • Verified ?is_extended_promotional=true filter returns only promotional components
  • Verified existing tests continue to pass
  • Verified code passes biome formatting checks

Closes #92

🤖 Generated with Claude Code

…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]>
Comment on lines +82 to +102
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)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +11 to +31
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)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

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