feat: Add is_extended_promotional column to all component tables#126
feat: Add is_extended_promotional column to all component tables#126sirrodgepodge wants to merge 2 commits intotscircuit:mainfrom
Conversation
- Add extended_promotional field to Component and VComponent interfaces - Add is_extended_promotional to BaseComponent and all derived table specs - Add is_extended_promotional filter to components list and search API routes - Add Extended Promotional checkbox to components list UI - Add component-extended-promotional-index optimization - Update cf-proxy types and handlers - Update setup-db-optimizations to include new index
There was a problem hiding this comment.
Pull request overview
Adds support for an “extended promotional” component flag across the DB-derived component tables and exposes it through the UI/API so users can filter components that act as basic for a limited time (Issue #92).
Changes:
- Adds
is_extended_promotionalto derived tables/base types and updates generated Kysely/CF-proxy DB types accordingly. - Adds
is_extended_promotionalfiltering + response fields to/components/listand/api/search. - Adds a SQLite index optimization for
components.extended_promotional.
Reviewed changes
Copilot reviewed 44 out of 45 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/setup-db-optimizations.ts | Registers the new DB optimization for the extended promotional index. |
| routes/components/list.tsx | Adds query param + UI checkbox + JSON output field for is_extended_promotional. |
| routes/api/search.tsx | Adds query param filter + JSON output field for is_extended_promotional. |
| lib/db/optimizations/component-extended-promotional-index.ts | New optimization to add an index on components.extended_promotional. |
| lib/db/generated/kysely.ts | Updates generated DB interfaces to include the new column(s). |
| lib/db/derivedtables/component-base.ts | Extends BaseComponent with is_extended_promotional. |
| lib/db/derivedtables/accelerometer.ts | Propagates is_extended_promotional into the accelerometer derived table. |
| lib/db/derivedtables/adc.ts | Propagates is_extended_promotional into the ADC derived table. |
| lib/db/derivedtables/analog_multiplexer.ts | Propagates is_extended_promotional into the analog multiplexer derived table. |
| lib/db/derivedtables/battery_holder.ts | Propagates is_extended_promotional into the battery holder derived table. |
| lib/db/derivedtables/bjt_transistor.ts | Propagates is_extended_promotional into the BJT transistor derived table. |
| lib/db/derivedtables/boost_converter.ts | Propagates is_extended_promotional into the boost converter derived table. |
| lib/db/derivedtables/buck_boost_converter.ts | Propagates is_extended_promotional into the buck-boost converter derived table. |
| lib/db/derivedtables/capacitor.ts | Propagates is_extended_promotional into the capacitor derived table. |
| lib/db/derivedtables/dac.ts | Propagates is_extended_promotional into the DAC derived table. |
| lib/db/derivedtables/diode.ts | Propagates is_extended_promotional into the diode derived table. |
| lib/db/derivedtables/fpc_connector.ts | Propagates is_extended_promotional into the FPC connector derived table. |
| lib/db/derivedtables/fpga.ts | Propagates is_extended_promotional into the FPGA derived table. |
| lib/db/derivedtables/fuse.ts | Propagates is_extended_promotional into the fuse derived table. |
| lib/db/derivedtables/gas_sensor.ts | Propagates is_extended_promotional into the gas sensor derived table. |
| lib/db/derivedtables/gyroscope.ts | Propagates is_extended_promotional into the gyroscope derived table. |
| lib/db/derivedtables/header.ts | Propagates is_extended_promotional into the header derived table. |
| lib/db/derivedtables/io_expander.ts | Propagates is_extended_promotional into the IO expander derived table. |
| lib/db/derivedtables/jst_connector.ts | Propagates is_extended_promotional into the JST connector derived table. |
| lib/db/derivedtables/lcd_display.ts | Propagates is_extended_promotional into the LCD display derived table. |
| lib/db/derivedtables/led.ts | Propagates is_extended_promotional into the LED derived table. |
| lib/db/derivedtables/led_dot_matrix_display.ts | Propagates is_extended_promotional into the LED dot-matrix derived table. |
| lib/db/derivedtables/led_driver.ts | Propagates is_extended_promotional into the LED driver derived table. |
| lib/db/derivedtables/led_segment_display.ts | Propagates is_extended_promotional into the LED segment display derived table. |
| lib/db/derivedtables/led_with_ic.ts | Propagates is_extended_promotional into the LED-with-IC derived table. |
| lib/db/derivedtables/microcontroller.ts | Propagates is_extended_promotional into the microcontroller derived table. |
| lib/db/derivedtables/mosfet.ts | Propagates is_extended_promotional into the MOSFET derived table. |
| lib/db/derivedtables/oled_display.ts | Propagates is_extended_promotional into the OLED display derived table. |
| lib/db/derivedtables/pcie_m2_connector.ts | Propagates is_extended_promotional into the PCIe/M.2 connector derived table. |
| lib/db/derivedtables/potentiometer.ts | Propagates is_extended_promotional into the potentiometer derived table. |
| lib/db/derivedtables/relay.ts | Propagates is_extended_promotional into the relay derived table. |
| lib/db/derivedtables/resistor.ts | Propagates is_extended_promotional into the resistor derived table. |
| lib/db/derivedtables/resistor_array.ts | Propagates is_extended_promotional into the resistor array derived table. |
| lib/db/derivedtables/switch.ts | Propagates is_extended_promotional into the switch derived table. |
| lib/db/derivedtables/usb_c_connector.ts | Propagates is_extended_promotional into the USB-C connector derived table. |
| lib/db/derivedtables/voltage_regulator.ts | Propagates is_extended_promotional into the voltage regulator derived table. |
| lib/db/derivedtables/wifi_module.ts | Propagates is_extended_promotional into the WiFi module derived table. |
| lib/db/derivedtables/wire_to_board_connector.ts | Propagates is_extended_promotional into the wire-to-board connector derived table. |
| cf-proxy/src/handlers/index.ts | Adds is_extended_promotional as a supported filter in proxy table configs. |
| cf-proxy/src/db/types.ts | Updates CF-proxy DB types to include is_extended_promotional fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| package: c.package, | ||
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| description: c.description, |
There was a problem hiding this comment.
is_extended_promotional (and currently is_preferred) are derived from c.extended_promotional / c.preferred, but those columns are not selected in the select([...]) list from v_components, so they’ll always serialize as false/undefined. Include preferred and extended_promotional in the select list (or switch to selectAll) so the response/UI reflects the actual DB values.
| if (req.query.is_extended_promotional) { | ||
| query = query.where(sql.ref("extended_promotional"), "=", 1) | ||
| } |
There was a problem hiding this comment.
The new is_extended_promotional filter behavior isn’t covered by tests. Since this route already has route-level tests, please add at least one test that sets is_extended_promotional=true and asserts all returned components have extended_promotional set (and one that ensures mixed results when the param is omitted).
| if (req.query.is_extended_promotional) { | ||
| query = query.where("extended_promotional", "=", 1) | ||
| } |
There was a problem hiding this comment.
The new is_extended_promotional query param path isn’t covered by existing /api/search tests. Add a test that calls /api/search?is_extended_promotional=true (with/without q) and asserts the response only includes components where extended_promotional is truthy.
| in_stock: Boolean((c.stock || 0) > 0), | ||
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| drain_source_voltage: parseValue( |
There was a problem hiding this comment.
The new is_extended_promotional line in the returned object is mis-indented. This will cause the Biome format check to fail; please run bun run format (or fix indentation) before merging.
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| relay_type: (c as any).subcategory || "", |
There was a problem hiding this comment.
The new is_extended_promotional line is mis-indented in the returned object. This should be formatted to satisfy the repo’s Biome format check.
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| supply_voltage_min: parseValue(attrs["Input Voltage"]?.split("~")[0]), |
There was a problem hiding this comment.
The inserted is_extended_promotional property is mis-indented within the returned object. This should be formatted to satisfy the Biome format check.
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| forward_voltage: forwardVoltage, |
There was a problem hiding this comment.
The inserted is_extended_promotional property line is mis-indented relative to surrounding fields in the returned object. Please format this file (Biome) so the format-check CI job passes.
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| protocol: protocol || undefined, |
There was a problem hiding this comment.
The inserted is_extended_promotional property is mis-indented in this returned object. Please format this file so bun run format:check (Biome) passes.
| is_basic: Boolean(c.basic), | ||
| is_preferred: Boolean(c.preferred), | ||
| is_extended_promotional: Boolean(c.extended_promotional), | ||
| package: String(c.package || ""), | ||
| mounting_style: attrs["Mounting Style"] || null, |
There was a problem hiding this comment.
The inserted is_extended_promotional property is mis-indented in this returned object. Please format the file (Biome) so bun run format:check passes.
| { name: "is_basic", type: "boolean" }, | ||
| { name: "is_preferred", type: "boolean" }, | ||
| { name: "is_extended_promotional", type: "boolean" }, | ||
| ], |
There was a problem hiding this comment.
The newly added is_extended_promotional entry in extraColumns is mis-indented, which will cause bun run format:check (Biome) to fail. Please format this file (or fix indentation) before merging.
| ], | |
| ], |
/claim #92
Summary
Adds
is_extended_promotionalcolumn to components, enabling filtering for parts that act as basic for a limited time.Changes:
extended_promotionalfield toComponentandVComponentinterfaces in generated Kysely typesis_extended_promotionalboolean column to extraColumns and mapToTable logicis_extended_promotionalto the base interface/components/list): Added query param filter and UI checkbox for Extended Promotional/api/search): Addedis_extended_promotionalquery param filteris_extended_promotionalin component JSON outputidx_components_extended_promotionalindex on the components table