additional background job work
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m19s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m19s
This commit is contained in:
@@ -73,6 +73,8 @@ interface FlyerJobData {
|
||||
originalFileName: string;
|
||||
checksum: string;
|
||||
userId?: string;
|
||||
submitterIp?: string;
|
||||
userProfileAddress?: string;
|
||||
}
|
||||
|
||||
interface EmailJobData {
|
||||
@@ -100,7 +102,7 @@ interface CleanupJobData {
|
||||
export const flyerWorker = new Worker<FlyerJobData>(
|
||||
'flyer-processing',
|
||||
async (job: Job<FlyerJobData>) => {
|
||||
const { filePath, originalFileName, checksum, userId } = job.data;
|
||||
const { filePath, originalFileName, checksum, userId, submitterIp, userProfileAddress } = job.data;
|
||||
const createdImagePaths: string[] = [];
|
||||
let jobSucceeded = false;
|
||||
logger.info(`[Worker] Processing job ${job.id} for file: ${originalFileName}`);
|
||||
@@ -144,7 +146,12 @@ export const flyerWorker = new Worker<FlyerJobData>(
|
||||
|
||||
// 2. Call AI Service
|
||||
const masterItems = await db.getAllMasterItems(); // Fetch master items for the AI
|
||||
const extractedData = await aiService.extractCoreDataFromFlyerImage(imagePaths, masterItems);
|
||||
const extractedData = await aiService.extractCoreDataFromFlyerImage(
|
||||
imagePaths,
|
||||
masterItems,
|
||||
submitterIp,
|
||||
userProfileAddress
|
||||
);
|
||||
logger.info(`[Worker] AI extracted ${extractedData.items.length} items.`);
|
||||
|
||||
// 3. Save to Database
|
||||
@@ -258,6 +265,11 @@ export const analyticsWorker = new Worker<AnalyticsJobData>(
|
||||
const { reportDate } = job.data;
|
||||
logger.info(`[AnalyticsWorker] Starting report generation for job ${job.id}`, { reportDate });
|
||||
try {
|
||||
// Special case for testing the retry mechanism
|
||||
if (reportDate === 'FAIL') {
|
||||
throw new Error('This is a test failure for the analytics job.');
|
||||
}
|
||||
|
||||
// In a real implementation, you would call a database function here.
|
||||
// For example: await db.generateDailyAnalyticsReport(reportDate);
|
||||
await new Promise(resolve => setTimeout(resolve, 10000)); // Simulate a 10-second task
|
||||
|
||||
Reference in New Issue
Block a user