mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-04-25 00:36:32 +02:00
Fix manual refresh to respect AI disable flags
- Update refresh endpoint to use scrapeProductWithVoting instead of scrapeProduct - Pass skipAiVerification and skipAiExtraction flags from product settings - Also use preferred extraction method and anchor price for consistency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
be6dd6382e
commit
5e850aee18
1 changed files with 16 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Router, Response } from 'express';
|
||||
import { AuthRequest, authMiddleware } from '../middleware/auth';
|
||||
import { productQueries, priceHistoryQueries, stockStatusHistoryQueries } from '../models';
|
||||
import { scrapeProduct } from '../services/scraper';
|
||||
import { scrapeProductWithVoting, ExtractionMethod } from '../services/scraper';
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
|
@ -62,8 +62,21 @@ router.post('/:productId/refresh', async (req: AuthRequest, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Scrape product data including price and stock status (pass userId for AI verification)
|
||||
const scrapedData = await scrapeProduct(product.url, userId);
|
||||
// Get product settings for AI skip flags
|
||||
const preferredMethod = await productQueries.getPreferredExtractionMethod(productId);
|
||||
const anchorPrice = await productQueries.getAnchorPrice(productId);
|
||||
const skipAiVerification = await productQueries.isAiVerificationDisabled(productId);
|
||||
const skipAiExtraction = await productQueries.isAiExtractionDisabled(productId);
|
||||
|
||||
// Scrape product data with proper settings (same as scheduler)
|
||||
const scrapedData = await scrapeProductWithVoting(
|
||||
product.url,
|
||||
userId,
|
||||
preferredMethod as ExtractionMethod | undefined,
|
||||
anchorPrice || undefined,
|
||||
skipAiVerification,
|
||||
skipAiExtraction
|
||||
);
|
||||
|
||||
// Update stock status and record change if different
|
||||
if (scrapedData.stockStatus !== product.stock_status) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue