Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea Actions
879d956003 ci: Bump version to 0.9.51 [skip ci] 2026-01-07 07:11:22 +05:00
27eaac7ea8 fix the dang integration tests
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 27m15s
2026-01-06 18:10:47 -08:00
6 changed files with 21 additions and 3 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "flyer-crawler",
"version": "0.9.50",
"version": "0.9.51",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "flyer-crawler",
"version": "0.9.50",
"version": "0.9.51",
"dependencies": {
"@bull-board/api": "^6.14.2",
"@bull-board/express": "^6.14.2",

View File

@@ -1,7 +1,7 @@
{
"name": "flyer-crawler",
"private": true,
"version": "0.9.50",
"version": "0.9.51",
"type": "module",
"scripts": {
"dev": "concurrently \"npm:start:dev\" \"vite\"",

View File

@@ -103,6 +103,7 @@ export class FlyerAiProcessor {
jobData: FlyerJobData,
logger: Logger,
): Promise<AiProcessorResult> {
console.error(`[WORKER DEBUG] FlyerAiProcessor: extractAndValidateData called with ${imagePaths.length} images`);
logger.info(`Starting AI data extraction for ${imagePaths.length} pages.`);
const { submitterIp, userProfileAddress } = jobData;
const masterItems = await this.personalizationRepo.getAllMasterItems(logger);
@@ -159,6 +160,7 @@ export class FlyerAiProcessor {
}
logger.info(`Batch processing complete. Total items extracted: ${mergedData.items.length}`);
console.error(`[WORKER DEBUG] FlyerAiProcessor: Merged AI Data:`, JSON.stringify(mergedData, null, 2));
// Validate the final merged dataset
return this._validateAiData(mergedData, logger);

View File

@@ -253,7 +253,9 @@ export class FlyerFileHandler {
job: Job<FlyerJobData>,
logger: Logger,
): Promise<{ imagePaths: { path: string; mimetype: string }[]; createdImagePaths: string[] }> {
console.error(`[WORKER DEBUG] FlyerFileHandler: prepareImageInputs called for ${filePath}`);
const fileExt = path.extname(filePath).toLowerCase();
console.error(`[WORKER DEBUG] FlyerFileHandler: Detected extension: ${fileExt}`);
if (fileExt === '.pdf') {
return this._handlePdfInput(filePath, job, logger);

View File

@@ -69,6 +69,7 @@ export class FlyerProcessingService {
// Stage 1: Prepare Inputs (e.g., convert PDF to images)
stages[0].status = 'in-progress';
await job.updateProgress({ stages });
console.error(`[WORKER DEBUG] ProcessingService: Calling fileHandler.prepareImageInputs for ${job.data.filePath}`);
const { imagePaths, createdImagePaths } = await this.fileHandler.prepareImageInputs(
job.data.filePath,
@@ -76,6 +77,7 @@ export class FlyerProcessingService {
logger,
);
allFilePaths.push(...createdImagePaths);
console.error(`[WORKER DEBUG] ProcessingService: fileHandler returned ${imagePaths.length} images.`);
stages[0].status = 'completed';
stages[0].detail = `${imagePaths.length} page(s) ready for AI.`;
await job.updateProgress({ stages });
@@ -84,7 +86,9 @@ export class FlyerProcessingService {
stages[1].status = 'in-progress';
await job.updateProgress({ stages });
console.error(`[WORKER DEBUG] ProcessingService: Calling aiProcessor.extractAndValidateData`);
const aiResult = await this.aiProcessor.extractAndValidateData(imagePaths, job.data, logger);
console.error(`[WORKER DEBUG] ProcessingService: aiProcessor returned data for store: ${aiResult.data.store_name}`);
stages[1].status = 'completed';
await job.updateProgress({ stages });
@@ -97,7 +101,9 @@ export class FlyerProcessingService {
const primaryImagePath = imagePaths[0].path;
const imageFileName = path.basename(primaryImagePath);
const iconsDir = path.join(path.dirname(primaryImagePath), 'icons');
console.error(`[WORKER DEBUG] ProcessingService: Generating icon from ${primaryImagePath} to ${iconsDir}`);
const iconFileName = await generateFlyerIcon(primaryImagePath, iconsDir, logger);
console.error(`[WORKER DEBUG] ProcessingService: Icon generated: ${iconFileName}`);
// Add the newly generated icon to the list of files to be cleaned up.
// The main processed image path is already in `allFilePaths` via `createdImagePaths`.
@@ -120,6 +126,7 @@ export class FlyerProcessingService {
baseUrl,
);
console.error('[DEBUG] FlyerProcessingService transformer output URLs:', { imageUrl: flyerData.image_url, iconUrl: flyerData.icon_url });
console.error('[DEBUG] Full Flyer Data to be saved:', JSON.stringify(flyerData, null, 2));
stages[2].status = 'completed';
await job.updateProgress({ stages });
@@ -150,6 +157,12 @@ export class FlyerProcessingService {
});
flyerId = flyer.flyer_id;
} catch (error) {
// Capture specific validation errors and append context for debugging
if (error instanceof Error && error.message.includes('Invalid URL')) {
const msg = `DB Validation Failed: ${error.message}. ImageURL: '${flyerData.image_url}', IconURL: '${flyerData.icon_url}'`;
console.error('[ERROR] ' + msg);
throw new Error(msg);
}
if (error instanceof FlyerProcessingError) throw error;
throw new DatabaseError(error instanceof Error ? error.message : String(error));
}

View File

@@ -175,6 +175,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
if (jobStatus?.state === 'failed') {
console.error('[DEBUG] Job failed with reason:', jobStatus.failedReason);
console.error('[DEBUG] Job stack trace:', jobStatus.stacktrace);
console.error('[DEBUG] Job return value:', JSON.stringify(jobStatus.returnValue, null, 2));
console.error('[DEBUG] Full Job Status:', JSON.stringify(jobStatus, null, 2));
}
expect(jobStatus?.state).toBe('completed');