Skip to content

feat: Add is_extended_promotional column to all component tables#126

Open
sirrodgepodge wants to merge 2 commits intotscircuit:mainfrom
sirrodgepodge:feat/add-extended-promotional-column
Open

feat: Add is_extended_promotional column to all component tables#126
sirrodgepodge wants to merge 2 commits intotscircuit:mainfrom
sirrodgepodge:feat/add-extended-promotional-column

Conversation

@sirrodgepodge
Copy link

/claim #92

Summary

Adds is_extended_promotional column to components, enabling filtering for parts that act as basic for a limited time.

Changes:

  • Component model: Added extended_promotional field to Component and VComponent interfaces in generated Kysely types
  • All 37 derived tables: Added is_extended_promotional boolean column to extraColumns and mapToTable logic
  • BaseComponent: Added is_extended_promotional to the base interface
  • Components list route (/components/list): Added query param filter and UI checkbox for Extended Promotional
  • Search API (/api/search): Added is_extended_promotional query param filter
  • API responses: Include is_extended_promotional in component JSON output
  • DB optimization: Added idx_components_extended_promotional index on the components table
  • CF proxy: Updated types and handlers to support the new column

- 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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_promotional to derived tables/base types and updates generated Kysely/CF-proxy DB types accordingly.
  • Adds is_extended_promotional filtering + response fields to /components/list and /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.

Comment on lines 86 to 90
package: c.package,
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
description: c.description,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +64
if (req.query.is_extended_promotional) {
query = query.where(sql.ref("extended_promotional"), "=", 1)
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +54
if (req.query.is_extended_promotional) {
query = query.where("extended_promotional", "=", 1)
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 69 to 74
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(
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 64 to 68
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 || "",
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 79 to 83
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]),
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The inserted is_extended_promotional property is mis-indented within the returned object. This should be formatted to satisfy the Biome format check.

Copilot uses AI. Check for mistakes.
Comment on lines 101 to 105
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: String(c.package || ""),
forward_voltage: forwardVoltage,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 67 to 71
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: String(c.package || ""),
protocol: protocol || undefined,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The inserted is_extended_promotional property is mis-indented in this returned object. Please format this file so bun run format:check (Biome) passes.

Copilot uses AI. Check for mistakes.
Comment on lines 71 to 75
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,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The inserted is_extended_promotional property is mis-indented in this returned object. Please format the file (Biome) so bun run format:check passes.

Copilot uses AI. Check for mistakes.
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
],
],

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants