feat: optimize scan flow with WebP compression and fix admin metrics visibility

This commit is contained in:
2025-12-22 10:15:29 +01:00
parent f0588418c8
commit 5e35710b67
19 changed files with 477 additions and 332 deletions

View File

@@ -48,7 +48,7 @@ export async function analyzeBottleMistral(base64Image: string, tags?: string[],
}
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
const dataUrl = `data:image/jpeg;base64,${base64Data}`;
const dataUrl = `data:image/webp;base64,${base64Data}`;
const prompt = getSystemPrompt(tags ? tags.join(', ') : 'Keine Tags verfügbar', locale);

View File

@@ -57,7 +57,7 @@ export async function analyzeBottle(base64Image: string, tags?: string[], locale
{
inlineData: {
data: base64Data,
mimeType: 'image/jpeg',
mimeType: 'image/webp',
},
},
{ text: instruction },

View File

@@ -26,12 +26,13 @@ export async function saveBottle(
if (!finalImageUrl && base64Image) {
const base64Data = base64Image.split(',')[1] || base64Image;
const buffer = Buffer.from(base64Data, 'base64');
const fileName = `${userId}/${uuidv4()}.jpg`;
const isWebp = base64Image.startsWith('data:image/webp');
const fileName = `${userId}/${uuidv4()}.${isWebp ? 'webp' : 'jpg'}`;
const { error: uploadError } = await supabase.storage
.from('bottles')
.upload(fileName, buffer, {
contentType: 'image/jpeg',
contentType: isWebp ? 'image/webp' : 'image/jpeg',
upsert: true,
});