Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
622c919733 | ||
| c7f6b6369a |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "flyer-crawler",
|
||||
"version": "0.9.51",
|
||||
"version": "0.9.52",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "flyer-crawler",
|
||||
"version": "0.9.51",
|
||||
"version": "0.9.52",
|
||||
"dependencies": {
|
||||
"@bull-board/api": "^6.14.2",
|
||||
"@bull-board/express": "^6.14.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "flyer-crawler",
|
||||
"private": true,
|
||||
"version": "0.9.51",
|
||||
"version": "0.9.52",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently \"npm:start:dev\" \"vite\"",
|
||||
|
||||
@@ -543,6 +543,20 @@ export class AIService {
|
||||
logger.info(
|
||||
`[extractCoreDataFromFlyerImage] Entering method with ${imagePaths.length} image(s).`,
|
||||
);
|
||||
|
||||
// [TEST HOOK] Simulate an AI failure if the filename contains specific text.
|
||||
// This allows integration tests to verify error handling.
|
||||
if (imagePaths.some((f) => f.path.includes('ai-fail-test'))) {
|
||||
logger.warn('[TEST HOOK] Simulating AI failure for test file.');
|
||||
throw new Error('AI model failed to extract data.');
|
||||
}
|
||||
|
||||
// [TEST HOOK] Simulate a specific failure for the cleanup test
|
||||
if (imagePaths.some((f) => f.path.includes('cleanup-fail-test'))) {
|
||||
logger.warn('[TEST HOOK] Simulating AI failure for cleanup test.');
|
||||
throw new Error('Simulated AI failure for cleanup test.');
|
||||
}
|
||||
|
||||
const prompt = this._buildFlyerExtractionPrompt(masterItems, submitterIp, userProfileAddress);
|
||||
|
||||
const imageParts = await Promise.all(
|
||||
|
||||
@@ -64,7 +64,17 @@ export class FlyerRepository {
|
||||
*/
|
||||
async insertFlyer(flyerData: FlyerDbInsert, logger: Logger): Promise<Flyer> {
|
||||
console.error('[DEBUG] FlyerRepository.insertFlyer called with:', JSON.stringify(flyerData, null, 2));
|
||||
// [TEST HOOK] Simulate a database failure if the filename contains specific text.
|
||||
// This allows integration tests to verify error handling without mocking the entire DB connection.
|
||||
if (flyerData.file_name.includes('db-fail-test')) {
|
||||
logger.warn('[TEST HOOK] Simulating DB transaction failure for test file.');
|
||||
throw new Error('DB transaction failed for test.');
|
||||
}
|
||||
|
||||
try {
|
||||
// Sanitize icon_url: Ensure empty strings become NULL to avoid regex constraint violations
|
||||
const iconUrl = flyerData.icon_url && flyerData.icon_url.trim() !== '' ? flyerData.icon_url : null;
|
||||
|
||||
const query = `
|
||||
INSERT INTO flyers (
|
||||
file_name, image_url, icon_url, checksum, store_id, valid_from, valid_to, store_address,
|
||||
@@ -76,7 +86,7 @@ export class FlyerRepository {
|
||||
const values = [
|
||||
flyerData.file_name, // $1
|
||||
flyerData.image_url, // $2
|
||||
flyerData.icon_url, // $3
|
||||
iconUrl, // $3
|
||||
flyerData.checksum, // $4
|
||||
flyerData.store_id, // $5
|
||||
flyerData.valid_from, // $6
|
||||
|
||||
Reference in New Issue
Block a user