fix: improve image source handling in FlyerDisplay and adjust worker concurrency fallback
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m40s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m40s
This commit is contained in:
@@ -28,6 +28,11 @@ interface FlyerDisplayProps {
|
||||
export const FlyerDisplay: React.FC<FlyerDisplayProps> = ({ imageUrl, store, validFrom, validTo, storeAddress, onOpenCorrectionTool }) => {
|
||||
const dateRange = formatDateRange(validFrom, validTo);
|
||||
|
||||
// Determine the correct image source. If imageUrl is already a full URL (starts with http)
|
||||
// or is an absolute path (starts with /), use it directly. Otherwise, assume it's a relative
|
||||
// filename from the database and prepend the correct path.
|
||||
const imageSrc = imageUrl && (imageUrl.startsWith('http') || imageUrl.startsWith('/')) ? imageUrl : `/flyer-images/${imageUrl}`;
|
||||
|
||||
return (
|
||||
<div className="w-full rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 shadow-sm bg-white dark:bg-gray-900 flex flex-col">
|
||||
{(store || dateRange) && (
|
||||
@@ -56,7 +61,7 @@ export const FlyerDisplay: React.FC<FlyerDisplayProps> = ({ imageUrl, store, val
|
||||
)}
|
||||
<div className="bg-gray-100 dark:bg-gray-800">
|
||||
{imageUrl ? (
|
||||
<img src={`/flyer-images/${imageUrl}`} alt="Grocery Flyer" className="w-full h-auto object-contain max-h-[60vh] dark:invert dark:hue-rotate-180" />
|
||||
<img src={imageSrc} alt="Grocery Flyer" className="w-full h-auto object-contain max-h-[60vh] dark:invert dark:hue-rotate-180" />
|
||||
) : (
|
||||
<div className="w-full h-64 bg-gray-200 dark:bg-gray-700 rounded-lg flex items-center justify-center">
|
||||
<p className="text-gray-500">Flyer image will be displayed here</p>
|
||||
|
||||
@@ -224,7 +224,7 @@ export const flyerWorker = new Worker<FlyerJobData>(
|
||||
// Control the number of concurrent jobs. This directly limits parallel calls to the AI API.
|
||||
// It's sourced from an environment variable for easy configuration without code changes.
|
||||
// The Google AI free tier limit is 60 RPM, so a low concurrency is safe.
|
||||
concurrency: parseInt(process.env.WORKER_CONCURRENCY!, 10),
|
||||
concurrency: parseInt(process.env.WORKER_CONCURRENCY || '1', 10),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user