Skip to content

Print each chip vendor once, not once per chip - #128

Merged
openipc-ai merged 1 commit into
masterfrom
fix/silicon-strip-duplicates
Aug 28, 2026
Merged

Print each chip vendor once, not once per chip#128
openipc-ai merged 1 commit into
masterfrom
fix/silicon-strip-duplicates

Conversation

@openipc-ai

Copy link
Copy Markdown
Collaborator

Reported on dev: the homepage's "Runs on silicon by" strip lists
HiSilicon twenty-three times, Ingenic twenty-seven, SigmaStar thirty.

Cause

Mine, in #127. The strip used to read Vendor.order(:name), which counted
sensor-only makers as chip vendors. I moved it to the existing
Vendor.soc_vendors scope — which is right — but that scope is

left_joins(:socs).where.not(socs: { id: nil })

one row per SoC, not per vendor. So pluck(:name) returns a vendor's
name once for every chip it makes.

Fix

distinct on the scope, where the join is. It has exactly one caller, so
there is nothing else to reconcile, and a scope named soc_vendors should
mean one row per vendor whoever asks.

Why the test did not catch it

It asserted which names appeared and never that each appeared once, and
its fixture vendor had a single SoC — so it could not have told the
difference. It now creates a vendor with two chips and asserts the rendered
strip has no repeats. Checked against the unfixed scope first:

RelaunchPagesTest#test_the_silicon_strip_lists_chip_vendors,_not_sensor_makers
the strip repeats a vendor once per chip it makes.

Verification

bin/rails test 314 runs, 1497 assertions, 0 failures
new assertion against unfixed code fails, on the intended assertion

soc_vendors left-joins socs, so it yields one row per SoC. Switching the
homepage strip to it -- to stop counting sensor-only makers as silicon we
run on -- therefore replaced one bug with a louder one: the strip printed
HiSilicon twenty-three times, Ingenic twenty-seven, SigmaStar thirty.

distinct on the scope, where the join is. It has one caller, so there is
nothing else to reconcile, and a scope named soc_vendors ought to mean one
row per vendor regardless of who asks.

The test that was supposed to cover this asserted which names appeared and
never that each appeared once, and its fixture vendor had a single SoC, so
it could not have noticed either way. It now builds a vendor with two chips
and asserts the rendered strip has no repeats -- checked against the
unfixed scope first, where it fails on exactly that assertion.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Deduplicate chip vendors in the homepage silicon strip

🐞 Bug fix 🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Deduplicates SoC vendors so the homepage lists each chipmaker once.
• Strengthens homepage coverage with multi-SoC vendors and explicit uniqueness assertions.
Diagram

graph TD
  Socs["SoC records"] -->|joined by| VendorScope["Vendor scope"] -->|unique names| PagesController["Pages controller"] -->|renders once| HomeStrip["Silicon strip"]
Loading
High-Level Assessment

Adding distinct at the scope boundary is the best minimal fix because it enforces the scope's one-row-per-vendor contract for every caller. Rewriting the query with an inner join or EXISTS could also avoid duplicates, but would add unnecessary query restructuring for the single existing caller.

Files changed (2) +13 / -4

Bug fix (1) +4 / -1
vendor.rbReturn unique vendors from the SoC vendor scope +4/-1

Return unique vendors from the SoC vendor scope

• Adds 'distinct' to the joined vendor query so vendors with multiple SoCs appear only once. The accompanying comment documents why deduplication is required for the homepage strip.

app/models/vendor.rb

Tests (1) +9 / -3
relaunch_pages_test.rbCover duplicate chip vendors in the silicon strip +9/-3

Cover duplicate chip vendors in the silicon strip

• Creates two SoCs for one vendor and inspects only rendered silicon-strip names. The test now verifies chipmakers are included, sensor-only vendors are excluded, and no vendor name repeats.

test/controllers/relaunch_pages_test.rb

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit 2bd5e02 into master Aug 28, 2026
2 checks passed
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.

1 participant