mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-18 13:55:16 +02:00
Fix anchor price selection - prioritize anchor over method
The previous logic checked preferred method first, which could select a wrong price even when anchor price was available. Now: 1. PRIORITY 1: Anchor price - if user confirmed a price, find closest match (within 10% tolerance) across ALL candidates 2. PRIORITY 2: Preferred method - only used if no anchor match found 3. PRIORITY 3: Consensus voting Also added debug logging to trace anchor price saving and retrieval. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
389915a6ec
commit
8131017f3a
3 changed files with 31 additions and 29 deletions
|
|
@ -29,6 +29,8 @@ async function checkPrices(): Promise<void> {
|
|||
// Get anchor price for variant products (the price the user confirmed)
|
||||
const anchorPrice = await productQueries.getAnchorPrice(product.id);
|
||||
|
||||
console.log(`[Scheduler] Product ${product.id} - preferredMethod: ${preferredMethod}, anchorPrice: ${anchorPrice}`);
|
||||
|
||||
// Use voting scraper with preferred method and anchor price if available
|
||||
const scrapedData = await scrapeProductWithVoting(
|
||||
product.url,
|
||||
|
|
@ -37,6 +39,8 @@ async function checkPrices(): Promise<void> {
|
|||
anchorPrice || undefined
|
||||
);
|
||||
|
||||
console.log(`[Scheduler] Product ${product.id} - scraped price: ${scrapedData.price?.price}, candidates: ${scrapedData.priceCandidates.map(c => `${c.price}(${c.method})`).join(', ')}`);
|
||||
|
||||
// Check for back-in-stock notification
|
||||
const wasOutOfStock = product.stock_status === 'out_of_stock';
|
||||
const nowInStock = scrapedData.stockStatus === 'in_stock';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue