const { PrismaClient } = require('../generated/prisma'); const prisma = new PrismaClient(); // Generate random SVG logo based on team name function generateSVGLogo(teamName, size = 40) { // Use team name to generate consistent colors and patterns let hash = 0; for (let i = 0; i < teamName.length; i++) { hash = teamName.charCodeAt(i) + ((hash << 5) - hash); } const hue = hash % 360; const saturation = 60 + (hash % 30); const lightness = 40 + (hash % 30); const color = `hsl(${hue}, ${saturation}%, ${lightness}%)`; // Generate secondary color const secondaryHue = (hue + 180) % 360; const secondaryColor = `hsl(${secondaryHue}, ${saturation}%, ${lightness}%)`; // Choose a logo pattern based on hash const pattern = hash % 4; const initials = teamName.split(' ').map(w => w[0]).join('').toUpperCase().slice(0, 2); let svgContent = ''; switch (pattern) { case 0: // Circle with initials svgContent = `${initials}`; break; case 1: // Square with diagonal svgContent = `${initials}`; break; case 2: // Triangle svgContent = `${initials}`; break; case 3: // Diamond svgContent = `${initials}`; break; } return svgContent; } async function updateTeamLogos() { try { const teams = await prisma.team.findMany(); console.log(`Found ${teams.length} teams to update`); for (const team of teams) { const svgLogo = generateSVGLogo(team.name); await prisma.team.update({ where: { id: team.id }, data: { logo: svgLogo } }); console.log(`Updated ${team.name} with SVG logo`); } console.log('✅ All team logos updated successfully!'); } catch (err) { console.error('Error updating team logos:', err); } finally { await prisma.$disconnect(); } } updateTeamLogos();