Market comp uses base query instead of enriched query — gives wrong median for filtered searches #30

Closed
opened 2026-04-09 08:59:03 -07:00 by pyr0ball · 0 comments
Owner

Bug

When a search uses must_include with specific GPU models and a category filter, the market comp call still uses the bare base query (q = "laptop motherboard").

_run_comps() in api/main.py:371 calls get_completed_sales(q, pages) — not the filtered query.

Result: median captures all sold laptop parts (~$50) instead of boards with those GPUs ($250-$400). The vs_market field becomes noise ("445% above market").

Root Cause

Two issues:

  1. api/main.py: _run_comps() always uses bare q, ignoring must_include and category_id.
  2. app/platforms/ebay/scraper.py:529: get_completed_sales() never passes _sacat category param.

Fix Proposal

Short-term: Derive a smarter comp query in api/main.py. When must_include_mode == groups append the pivot term to q for the comp call (e.g. "laptop motherboard rtx 3070" instead of "laptop motherboard").

Full fix: Add category_id param to get_completed_sales() and pass it through. Add optional comp_query override so callers can specify a targeted query independent of the search query.

Impact

All searches with tight must_include filters show misleading market deltas. Trust scores are unaffected (scorer ignores market price), but vs_market in MCP output and UI is wrong.

## Bug When a search uses `must_include` with specific GPU models and a category filter, the market comp call still uses the bare base query (`q = "laptop motherboard"`). `_run_comps()` in `api/main.py:371` calls `get_completed_sales(q, pages)` — not the filtered query. Result: median captures all sold laptop parts (~$50) instead of boards with those GPUs ($250-$400). The `vs_market` field becomes noise ("445% above market"). ## Root Cause Two issues: 1. `api/main.py`: `_run_comps()` always uses bare `q`, ignoring `must_include` and `category_id`. 2. `app/platforms/ebay/scraper.py:529`: `get_completed_sales()` never passes `_sacat` category param. ## Fix Proposal **Short-term:** Derive a smarter comp query in `api/main.py`. When `must_include_mode == groups` append the pivot term to `q` for the comp call (e.g. `"laptop motherboard rtx 3070"` instead of `"laptop motherboard"`). **Full fix:** Add `category_id` param to `get_completed_sales()` and pass it through. Add optional `comp_query` override so callers can specify a targeted query independent of the search query. ## Impact All searches with tight `must_include` filters show misleading market deltas. Trust scores are unaffected (scorer ignores market price), but `vs_market` in MCP output and UI is wrong.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/snipe#30
No description provided.